0

I have a loop that parses and works on a lot of data and it takes a long time. While it works away, the screen is blank and im wondering if there is a way to put a loader or counter up?

Since it does a finite amount of work, I thought I could just update the progress from within the loop but further readings has revealed that it wasn't possible.

Any ideas? Thanks

matthieu
  • 109
  • 2
  • 9
  • What prevents it from being possible within a loop? Once you work out any scope issues could you simply call a function to update the status on screen? I know the GUI can be slow sometimes at updating itself. If this is the case with your code you could consider chunking the status update, like only report status every 10 iterations. What issues are you running in to? – ToddBFisher Dec 02 '11 at 00:50

3 Answers3

7

The first step would be to turn your process into chunks that will complete quickly enough to keep your application responsive.

Then, start a timer that runs as fast as possible. On each TIMER event, complete as many chunks as possible while under a certain threshold. This will slow the overall process down, so you want the threshold to be as high as possible.

You can check out my AsyncSWFModifier class for a working example. This is a base class I extend, overriding the run method. I won't paste it here because there are some irrelevant details in that class.

Sean Fujiwara
  • 4,506
  • 22
  • 34
1

Those answers are right, the main problem being that Flash Player is single threaded.

LoremIpsum
  • 4,328
  • 1
  • 15
  • 17
0

Make your variables private (out of the method scope), make some Timer to trigger method, and you'll get some pseudo-threading which won't lock your UI.

ncreated
  • 641
  • 1
  • 5
  • 14