I've got a few data processing functions in a Flex app I'm developing
that have to do some heavy lifting and require some time to finish
executing. I'm using cairngorm in this app, and the work is done on
the result handler of the command. I was surprised to see that this
function completely stalled the application until it finished
executing. For some reason since this was done on the result of an
event, I thought it would be executed in some background thread. I
really don't care how long it takes to process, I just want the UI to
be usable while it does its work.

I did some more tinkering and I discovered that event handling in Flex
was not working the way I believed. When I call dispatchEvent in a
function, any functions registered as listeners to this event run to
completion before the next line of code is executed. I thought the
"event flow" in Flex would be handled in a different thread some how
so that dispatchEvent would return to the calling function immediately
and you could go on with your work, all the listeners would be
executed at some later time.

Does anyone have any good insight about where "heavy lifting" should
be done in Flex? If everything happens serially like this it seems
like structuring a fairly large application would be tough to do. You
almost always need a place to do "background work" that is not time
critical.

Any responses are appreciated

Reply via email to