A quick google indicates that, as Manish says, current thinking is to
use timer for this type of work.

 

In addition to the libraries, Manish mentions, look at Alex's
article/class:

http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html

 

Also there is an explanation in the flex cookbook:

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails
&productId=2&postId=12026

 

Tracy

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Charlie Hubbard
Sent: Tuesday, December 23, 2008 11:07 AM
To: [email protected]
Subject: Re: [flexcoders] Performance and UI failing to update?

 

Tracy,

Before I started parsing the file it actually worked simply iterating
over the files and adding them to the DB without processing them.
After I started parsing the files I started getting this halting of
the UI.

Do you have any more details about how your technique was different?
Maybe a quick excerpt of code could help clarify your technique.

Thanks,
Charlie

On Tue, Dec 23, 2008 at 10:26 AM, Tracy Spratt <[email protected]
<mailto:tspratt%40lariatinc.com> > wrote:
> I have used this technique to break up long running processes.
>
>
>
> But I use two functions and two instance variables so that the
function of
> the iterator is entirely separate from the processor.
>
>
>
> The way you are doing it , essentially recursively, may be causing the
> problem.
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Charlie Hubbard
> Sent: Tuesday, December 23, 2008 8:35 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Performance and UI failing to update?
>
>
>
> 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