2 Replies Latest reply on May 11, 2011 7:40 AM by UbuntuPenguin

    Running some functions in the background - Flex mobile




      I have an application which allows the user to take a picture and upload it to the cloud. after the picture is taken, I'm performing some manipulation which takes 10 - 20 seconds. is there a way to do that in the background so it won't affect the user app flow.



        • 1. Re: Running some functions in the background - Flex mobile
          pauland Level 4

          There's no concept of "background" processing or multi threading in Flex just yet.


          In the past I have written processing routines that are processor-intensive, in such a way that they do some processing then stop, allowing the UI to function and then resume them after a moment. Basically, you need to be able to keep the current state periodically and then restart processing via a timed event, picking up where you left off.


          Also be aware that mobile platforms have limited resources and apps can be asked to shut down at any moment, 10-20 seconds of inactivity will not be acceptable on some platforms.

          • 2. Re: Running some functions in the background - Flex mobile
            UbuntuPenguin Level 4

            To expound on what pauland said, Flex is single threaded.  Which means that a long running process processor intensive process WILL affect the UI performance.  There are two options I can think of one can take to implement this.  The first being, don't do any heavy processing on the UI side.  The UI side is just that, the user interface side so its performance in conveying information to the user takes precedence over everything else.  If you want to do heavy processing try to do it on the backend where you can manage your resources better.  The last option is to use Greenthreading which basically allows the UI to do the stuff it needs to while taking care of a long running task.