Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex equivalent of ProcessMessages and unresponsive UI during long loops
    primarykey
    data
    text
    <p>I find that my Flex application's UI becomes unresponsive during very long processing loops (tens of seconds). For example, while processing very large XML files and doing something per-element...</p> <p>Is there an equivalent of "ProcessMessages"? That is, a call that would tell Flex to continue responding to UI events, even in the middle of some long loop, so that the UI doesn't become unresponsive?</p> <p><strong>I'm aware Flex is single threaded by design</strong>. That's exactly why I'm looking for something like ProcessMessages() - a function that allows <strong>single-threaded reentrant</strong> applications (like in VB, or single-threaded message loop based C++ applications) to remain responsive during long operations. </p> <p><strong>Summary of Answers</strong></p> <ol> <li>There's no built-in function like <code>HandleEvents()</code> or <code>ProcessMessages()</code> in Flex.</li> <li>Using some sort of callback mechanism to iteratively process chunks of a long computation process, while yielding to the runtime between chunks, thus enabling it to be responsive, is the only way to maintain a responsive UI during long computations.</li> <li>Ways of accomplishing the above are: <ol> <li>Using the <code>enterFrame</code> event, which is called whenever the Flash "movie" layer below the Flex application refreshes its frame (which is something like 20fps).</li> <li>Using a timer.</li> <li>Using <code>UIComponent.callLater()</code> which schedules work to be done "later". (as the docs <a href="http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#callLater()" rel="noreferrer">say</a>: <code>Queues a function to be called later. Before each update of the screen, Flash Player or AIR calls the set of functions that are scheduled for the update.</code></li> <li>Using intentionally triggered mouse/keyboard events to create pseudo "worker threads", as in <a href="http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html" rel="noreferrer">this example</a>.</li> </ol></li> </ol> <p>If there are further suggestions, or if I left out anything, please feel free to edit this (now) wiki piece.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload