I'm writing an AIR application where I have a very long operation that
I need to run in the background.  I know Actionscript doesn't have
threads so I'm trying to simulate that using cooperative multi-tasking
by breaking up my job into smaller pieces.  I'm basically trying to
parse an XML file, iterating over the nodes in that XML document,
parsing the file that node refers to, add an entry to the SQL lite DB.
 The parsing of the XML is done separately from the iteration, and
each iteration of the loop over the nodes is done using
UIComponent.callLater().  So my algorithm looks pretty close to
something of this form:

function doIteration( currentIndex : int, totalIndex: int ) : void {
   var current : Object = objects[ currentIndex ];
   doSomething( current );
   callLater( doIteration, [ currentIndex + 1, totalIndex ] );
}

My expectation is that by using callLater that will allow my UI to
paint and update between each iteration of my loop.  However, that
doesn't seem to be the case.  When my application starts this process
it updates very infrequently, and freezes most of the time.  I can put
trace statements in my loop and see that it's processing loads of
files very quickly, but the UI never gets updated.

How does Flash behave when it's under a load like this?  It runs as 12
frames/s, and I know that callLater is done at the end of each frame.
What happens if that process run is longer than 80ms/frame (1000ms/s
divided by 12 frames / s)?  Does it ever catch up?

Thanks
Charlie

Reply via email to