Handling long tasks

Hi,
I wanted to know what's the best way to handle long tasks in
Flex.
In my application, I have a heavy function that processes
lots of data from an XML file. When this function is called, the
whole app freezes. Even the busyCursor freezes and stop turning,
and I get the OS cursor for non-responsive application (on MacOSX a
multi-colored turning wheel).
Is there a way to prevent such problems ?

there was a Interesting Topic about it here, and guys cam eup
with some interesting Ideas, one of them was to let other swf do it
for you with LocalConnection basically utilizing Browsers multi
threading capabilities.
take a look at this :
thread
1
and
this
thread
2

Similar Messages

  • Handle long-running EDT tasks (f.i. TreeModel searching)

    Note: this is a cross-post from SO
    http://stackoverflow.com/questions/9378232/handle-long-running-edt-tasks-f-i-treemodel-searching
    copied below, input highly appreciated :-)
    Cheers
    Jeanette
    Trigger is a recently re-detected SwingX issue (https://java.net/jira/browse/SWINGX-1233): support deep - that is under collapsed nodes as opposed to visible nodes only, which is the current behaviour - node searching.
    "Nichts leichter als das" with all my current exposure to SwingWorker: walk the TreeModel in the background thread and update the ui in process, like shown in a crude snippet below. Fest's EDT checker is happy enough, but then it only checks on repaint (which is nicely happening on the EDT here)
    Only ... strictly speaking, that background thread must be the EDT as it is accessing (by reading) the model. So, the questions are:
    - how to implement the search thread-correctly?
    - or can we live with that risk (heavily documented, of course)
    One possibility for a special case solution would be to have a second (cloned or otherwise "same"-made) model for searching and then find the corresponding matches in the "real" model. That doesn't play overly nicely with a general searching support, as that can't know anything about any particular model, that is can't create a clone even if it wanted. Plus it would have to apply all the view sorting/filtering (in future) ...
    // a crude worker (match hard-coded and directly coupled to the ui)
    public static class SearchWorker extends SwingWorker<Void, File> {
        private Enumeration enumer;
        private JXList list;
        private JXTree tree;
        public SearchWorker(Enumeration enumer, JXList list, JXTree tree) {
            this.enumer = enumer;
            this.list = list;
            this.tree = tree;
        @Override
        protected Void doInBackground() throws Exception {
            int count = 0;
            while (enumer.hasMoreElements()) {
                count++;
                File file = (File) enumer.nextElement();
                if (match(file)) {
                    publish(file);
                if (count > 100){
                    count = 0;
                    Thread.sleep(50);
            return null;
        @Override
        protected void process(List<File> chunks) {
            for (File file : chunks) {
                ((DefaultListModel) list.getModel()).addElement(file);
                TreePath path = createPathToRoot(file);
                tree.addSelectionPath(path);
                tree.scrollPathToVisible(path);
        private TreePath createPathToRoot(File file) {
            boolean result = false;
            List<File> path = new LinkedList<File>();
            while(!result && file != null) {
                result = file.equals(tree.getModel().getRoot());
                path.add(0, file);
                file = file.getParentFile();
            return new TreePath(path.toArray());
        private boolean match(File file) {
            return file.getName().startsWith("c");
    // its usage in terms of SwingX test support
    public void interactiveDeepSearch() {
        final FileSystemModel files = new FileSystemModel(new File("."));
        final JXTree tree = new JXTree(files);
        tree.setCellRenderer(new DefaultTreeRenderer(IconValues.FILE_ICON, StringValues.FILE_NAME));
        final JXList list = new JXList(new DefaultListModel());
        list.setCellRenderer(new DefaultListRenderer(StringValues.FILE_NAME));
        list.setVisibleRowCount(20);
        JXFrame frame = wrapWithScrollingInFrame(tree, "search files");
        frame.add(new JScrollPane(list), BorderLayout.SOUTH);
        Action traverse = new AbstractAction("worker") {
            @Override
            public void actionPerformed(ActionEvent e) {
                setEnabled(false);
                Enumeration fileEnum = new PreorderModelEnumeration(files);
                SwingWorker worker = new SearchWorker(fileEnum, list, tree);
                PropertyChangeListener l = new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            //T.imeOut("search end ");
                            setEnabled(true);
                            ((SwingWorker) evt.getSource()).removePropertyChangeListener(this);
                worker.addPropertyChangeListener(l);
                // T.imeOn("starting search ... ");
                worker.execute();
        addAction(frame, traverse);
        show(frame)
    }

    At the end of the day, it turned out that I asked the wrong question (or right question in a wrong context ;-): the "problem" arose by an assumed solution, the real task to solve is to support a hierarchical search algorithm (right now the AbstractSearchable is heavily skewed on linear search).
    Once that will solved, the next question might be how much a framework can do to support concrete hierarchical searchables. Given the variety of custom implementations of TreeModels, that's most probably possible only for the most simple.
    Some thoughts that came up in the discussions here and the other forums. In a concrete context, first measure if the traversal is slow: most in-memory models are lightning fast to traverse, nothing needs to be done except using the basic support.
    Only if the traversal is the bottleneck (as f.i. in the FileSystemModel implementations of SwingX) additional work is needed:
    - in a truly immutable and unmodifiable TreeModel we might get away with read-only access in a SwingWorker's background thread
    - the unmodifiable precondition is violated in lazy loading/deleting scenarios
    there might be a natural custom data structure which backs the model, which is effectively kind-of "detached" from the actual model which allows synchronization to that backing model (in both traversal and view model)
    - pass the actual search back to the database
    - use an wrapper on top of a given TreeModel which guarantees to access the underlying model on the EDT
    - "fake" background searching: actually do so in small-enough blocks on the EDT (f.i. in a Timer) so that the user doesn't notice any delay
    Whatever the technical option to a slow search, there's the same usability problem to solve: how to present the delay to the end user? And that's an entirely different story, probably even more context/requirement dependent :-)
    Thanks for all the valuable input!
    Jeanette

  • How does Flex handled long computation tasks?

    Hi
    I am using Flex3 with Java. I need to print a large document after doing some processing on it, which require about 15 seconds(varying depending on size of document). Currently, the browser will hang for around 15 seconds and after that the printing starts.
    I want to figure out how to take care of the following items
    User should be able to execute long tasks, even if the cumputaion time takes longer time, say 1 min.
    Any option for multi-threads, so that i can split the processing job to minimise the computation time.
    Option to Cancel the execution in between.
    Avoid the freezing of UI - currently, my browser is getting stuck while flex executes the print job
    Also, can I incrementally render the browser with some data during the ciompuutaion so as to engage the user to reduce the effect of computaion delay.
    Thanks
       Rakesh

    Unfortunately, the current Flash Player does not support multiple threads in ActionScript. However, the Player team is aware of the desire by developers for some form of concurrent processing and they're thinking about how to satisfy it.
    In the meantime, if you have a lot of ActionScript to execute, you have to develop some kind of "green threading" (http://en.wikipedia.org/wiki/Green_threads) of your own, or find a library that does it. The basic idea would be to use an enterFrame handler (or a Timer) and a work queue to do only a reasonable amount of computation per frame.
    Gordon Smith
    Adobe Flex SDK Team

  • How to use the Latest End to handle overdue task?

    Experts,
      How to use the Latest End to handle overdue task?
      Thanks you very much!
    Ken.li

    Hi KL,
    could you give more details to get more from the Forum Experts.
    Just to give you an example. If you using a User Decision step and you want a Deadline to be set, click on the Latest End tab for the User Decision Step, there is a Refer/Date/Time column, list out 'Work item creation'.
    Below you would find Time column, enter appropriate period.
    If you want a message to be escalated to someone after the period that you entered above has passed, you can enter the recipient in the column 'Recipient of message'.
    Hope it helps.
    Aditya
    P.S - how good your query is, better answers you can expect from others.

  • How to Handle Long running alerts in process chain...Urgent!!!

    Hi All,
    I am trying to find ways for handling long running alerts in process chains.
    I need to be sending out mails if the processes are running for longer than a threshold value.
    I did check this post:
    Re: email notification in process chain
    Appreciate if anyone can forward the code from this post or suggest me other ways of handling these long running alerts.
    My email id is [email protected]
    Thanks and Regards
    Pavana.

    Hi Ravi,
    Thanks for your reply. I do know that i will need a custom program.
    I need to be sending out mails when there is a failure and also when process are running longer than a threshold.
    Please do forward any code you have for such a custom program.
    Expecting some help from the ever giving SDN forum.
    Thanks and Regards
    Pavana
    Message was edited by:
            pav ana

  • Why, when I sync my iPhone does it always take all my apps out of their neat sorted little boxes of twelve Apps organised by a commonality and rearrange them over a dozen screens in random order? Each time I sync, I have a 1hr long task of relocating apps

    Why, when I sync my iPhone does it always take all my apps out of their neat sorted little boxes of twelve Apps organised by a commonality and rearrange them over a dozen screens in random order? Each time I sync, I have a 1hr long task of relocating apps.
    Why no tleave them spread out I hear you ask... That is not practicable. I then have 12 pages to scan rather than just two. I need a solution... :-P

    I realize this is an old thread but I'm having the same problem after upgrading my software today. Kinda surprised there are no solutions at all with 88 views.  I have an iPod touch btw, not an iPhone, but it prob wouldn't make much difference in this case.
    The thing is, I get the screen(s) looking EXACTLY as I want on iTunes...just perfect (which is what I believe everyone else is experiencing as well).  When we go to sync tho, it does whatever it wants to do.  After syncing, all the apps are there, it's just that for me, it puts them in some type of random order.  I have 72 apps and this is absolutely ridiculous!
    Thanks in advance for any fixes anyone might have...

  • Recently updated to 3.8.2 v1.1 and since then my mac crashes a lot, and can't handle simple tasks. Has anyone else had this problem?

    I recently got told about the new software update for OS Yosemite.  It was version 3.8.2 v1.1 and since then my mac crashes a lot, and can't handle simple tasks. Like playing a 3 minute song, checking emails, and even whilst typing this its crashed so many more times than i've lost count. Has anyone else had this problem? And what do you recommend I do?

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled in OS X 10.9 or earlier, or if a firmware password is set, or if the startup volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

  • How to handle long lines in a JAD file?

    Hi all,
    setting MIDlet permissions in a JAD file easily expands the length of one line so that they need to get wrapped into 2 or more lines. AFAIK JADs actually are manifest files and the manifest file spec says that a line continuation is marked by a line beginning with a single space. I use Ant to create the JAD file and Ant's manifest task does it exactly like this. Example:
    MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client,j
    avax.microedition.io.Connector.socketThis works on my Sony Ericsson phone and in the MicroEmu emulator, but the WTK (2.5.2) emulator complains about that by throwing an exception:
    com.sun.midp.midletsuite.InvalidJadException: Reason = 28
         at com.sun.midp.midletsuite.JadProperties.partialLoad(+259)
         at com.sun.midp.midletsuite.JadProperties.load(+8)
         at com.sun.midp.dev.DevMIDletSuiteImpl.create(+252)
         at com.sun.midp.dev.DevMIDletSuiteImpl.create(+74)
         at com.sun.midp.main.Main.runLocalClass(+20)
         at com.sun.midp.main.Main.main(+80)So who is wrong here?
    Thanks for some information!
    Best regards,
    Brian

    MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client,j
    avax.microedition.io.Connector.socketif memory serves, inability to handle stuff like above is a known WTK bug.
    Try workarounds like "glueing" permissions into single (long) line or splitting them on commas

  • How to handle long Waits in BPEL?

    Hi,
    We are having a requirement to include a wait of 30 mins in BPEL process. But if this is done, the calling process will time out.
    How do we handle such long waits? If we increase the transaction time out period to 30 min, will it be a performance issue?

    Hi,
    I need to call a external process that could take along time to be resolved. Basically this external process could require human procesess.
    When I call the external process, this one decides if the BPELProces must wait for a future response or could continue without wait.
    Some one has a BPEL example for this kind of process ?
    This an example of my process (The search step is complex process to evaluate and I could not call twice to the external process (cost issues))
    1. BPEL calls external process
    2. external process searchs into the stock for the required product
    2.1 if the required product exists then the external process wait for a human task to be resolved into its internal WorkFlow application. Then BPEL must wait for the future answer
    2.2 if the required product does not exist then the external Process response to BPEL with No-Stock
    Thanks In Advanced
    Edited by: Paúl Pasquel on Sep 15, 2009 10:49 AM
    Edited by: Paúl Pasquel on Sep 15, 2009 10:59 AM

  • 2 GB memory ample enough to handle iMovie tasks?

    Hello. I'm about to get a 2.33 GHz iMac with 2 GB memory. If any of discussion-board users have 2 GB memory, I'm curious if any of you find your machines locking up or not up to the task of handling iMovie projects in any way.
    Yea, yea: I know: More memory is better, but I'm trying to contain the costs of the new machine as much as possible. Still, if 3 GB of memory is absolutely needed, I just wonder if I should cut the costs elsewhere, like with the graphics card, screen size, pre-installed apps, etc.
    Any feedback is much appreciated.

    I'm with Klaus - size isn't everything, but it helps...
    on my antiqué hardware, an upgrading from 512 to 1GB of RAM resulted into an enormous increase of speed - not measured, I'm no technician, but I could "feel" the increase clearly... I think, my slow paced machine (450MHz) does show more dramatically the use of more RAM...
    I was told on my German board, that MacOsX "loves" lots of RAM...- I think, with 1 - 2GB you're on the safe side...

  • SAP R/3 Transports : How to handle long pending transports ?

    How to stop active transport process?
    Hi.
    Generally we transport only one TR at a time.
    If we find that any transport is stuck for any reason.
    How do we resolve this.
    When we tried to delete the Long pending transport entry, it says, long text not found. 
    The problem is, we started one transport. It got stuck for more than 30 min.
    and when we tried to delete the entry it was giving some error of long text not found.
    We tried to start another. And it also got stuck.
    How do we really handle such issues of transports.
    Though, one could say, restart of server, is the only option because there is nothing much can be done when the transport is done, one at a time, as a practice.
    Can sap not handle requests - one by one, even if the practice is to transport one TR at a time .
    Why is the system getting confused and blocks further transport requests too.
    Can anyone advise.
    Thanks
    indu

    How to stop active transport process?
    Hi.
    Generally we transport only one TR at a time.
    If we find that any transport is stuck for any reason.
    How do we resolve this.
    When we tried to delete the Long pending transport entry, it says, long text not found. 
    The problem is, we started one transport. It got stuck for more than 30 min.
    and when we tried to delete the entry it was giving some error of long text not found.
    We tried to start another. And it also got stuck.
    How do we really handle such issues of transports.
    Though, one could say, restart of server, is the only option because there is nothing much can be done when the transport is done, one at a time, as a practice.
    Can sap not handle requests - one by one, even if the practice is to transport one TR at a time .
    Why is the system getting confused and blocks further transport requests too.
    Can anyone advise.
    Thanks
    indu

  • ITunes Version 11.0.4 (4) cannot handle long URLs

    One of my iTunes playlists contains URLs of radio stations that stream music to my computer. This works fine, EXCEPT FOR ONE STATION that has a very long URL that will not fit in the one line that iTunes allows in its small editing window, so iTunes continues the URL (which iTunes calls Where:) to a second line, but then iTunes does not know how to handle this second line, and so the music from this station will not stream. I tried editing the URL by adding a backslash to the URL just at the line break, but this did not work either. If I put this long URL into my Safari or Firefox browser, the station streams perfectly to my computer. But this is awkward, and not satisfactory compared to iTunes which is wonderful when it works........ The URL is: http://socialstreamingplayer.crystalmedianetworks.com/radio/khfm
    which iTunes breaks after radio/ so that khfm appears by itself on a second line and iTunes does not know how to handle this.
    Is there a solution for this problem?

    Unless I'm missing something, this is not a problem with iTunes. I can drag out the window so that the URL doesn't wrap but that still doesn't work. Going directly to the web site, the stream in question appears to be Flash-based and hence is not going to work in iTunes.
    Regards.

  • How do you handle long strings between JSP forms and Oracle?

    I am using Apache 1.3.12 with JServ 1.1 and Oracle 8.0.4 on NT4 development Server.
    I am developing an application where one component allows authors to contribute articles or comments via a JSP page. I am noticing a problem when the info in the form gets too long (> 2000 characters). 99% of the inserts fall well within this limitation. The remaining 1% is sufficiently significant that I can't use a VARCHAR. It seems that SQL*NET chokes on large strings.
    My immediate workaround for these messages is to break them up into segments. Instead of storing the text or a message directly in a message table, I've added another table, msg_text, with columns msg_id, seg_num, and seg_text. On insert the message is split into segments limited to the smaller of the query limit and database varchar limit, minus the overhead of the sql query. This makes for an ugly insert operation, though and I would very interested to see if anyone out there has a better way to accomplish this task directly with CLOBs.

    The apparent problem with LONGs is that, of course, you can only have one per table.
    I had exactly this problem and ended up with several tables for one Business Entity, which is not really satisfactory.
    For the next phase of the Project, I will investigate:
    Putting these tables into a View.
    Putting Instead Of triggers on the View to "synchronise" changes to all underlying tables.
    Basing my BC4J Entity Object on the View...
    ... and I hope that Bob will be my uncle.
    I'd be interested to hear from anyone who has already tried this, or you if you give it a go.
    Rich

  • Handling long running processes in APEX

    Hello Experts,
    I need your help!
    I would like to call a long running PL-Proc from an Apex-App. So I build a page for the parameters with the wizzard - all fine.
    Pressing the button starts the pl-proc - thats also fine.
    Problem: While the PL-Proc is running, there is no activity signaled in the browser. There is no way to see, that something is running in the background.
    After the pl-proc is finished, the branch to an other site took place - so the "after process" action is working as desired.
    I tried "javascript:html_Submit_Progress(this);" - but this is not a solution because there is only a very short time to reload the page itself. The PL-Proc need much more time.
    Is there a way to show the user, that background action is running?
    Any Ideas?
    Thanks for your help!
    Kind regards,
    Frank

    A few things to keep in mind. The animated gif solutions don't show a true progress bar indicator, it's just an animation on a loop. If the process takes too long, you will hit the session timeout value defined for Oracle HTTP Server.
    Another thought is this. In the code that is the long running process, make calls to [dbms_application_info.set_session_longops|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_appinf.htm#i996999] that indicate the real progress in the code. Then have a page that queries v$session_longops and refreshes every x (say 5 seconds). That page could even have an animated gif on it to indicate there is still activity.
    Tyler Muth
    http://tylermuth.wordpress.com
    [Applied Oracle Security: Developing Secure Database and Middleware Environments|http://www.amazon.com/gp/product/0071613706?ie=UTF8&tag=tylsblo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0071613706]

  • Displaying loading busy popup when performing long task.

    Dear All,
    I am refering sample #27 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html as i came across the thread Re: Cursor busy state
    But the solution is not working in my scenario following is my code.
    JAVASCRIPT
    function enforcePreventUserInput(evt) {
    var popTask = AdfPage.PAGE.findComponentByAbsoluteId('popTask');
    if (popup != null) {
    AdfPage.PAGE.addBusyStateListener(popTask, handleBusyState);
    evt.preventUserInput();
    //JavaScript call back handler
    function handleBusyState(evt) {
    var popTask = AdfPage.PAGE.findComponentByAbsoluteId('popTask');
    if (popTask != null) {
    if (evt.isBusy()) {
    popTask.show();
    else {
    popTask.hide();
    AdfPage.PAGE.removeBusyStateListener(popTask, handleBusyState);
    <af:selectOneChoice required="#{bindings.EMAIL_TEMPLATE_LOV_VO11.hints.mandatory}"
    shortDesc="#{bindings.EMAIL_TEMPLATE_LOV_VO11.hints.tooltip}"
    id="emailTemplate" simple="true"
    valueChangeListener="#{backingBeanScope.generate_backing.templateSelected}"
    autoSubmit="true"
    valuePassThru="true">
    <af:clientListener method="enforcePreventUserInput" type="valueChange"/>
    <f:selectItem id="select" itemLabel="<-Select->"
    itemValue="-1"/>
    <af:forEach var="row"
    items="#{bindings.EMAIL_TEMPLATE_LOV_VO1Iterator.allRowsInRange}">
    <f:selectItem itemValue="#{row.attributeValues[0]}"
    itemLabel="#{row.attributeValues[1]}"/>
    </af:forEach>
    </af:selectOneChoice>
    <af:popup id="popTask" contentDelivery="immediate">
    <af:dialog id="d2" type="none" title="Please wait ..."
    closeIconVisible="false">
    <af:panelGroupLayout id="pgl1" layout="vertical">
    <af:image source="/Images/oralogo_small.gif" id="i1"/>
    <af:image source="/Images/pleasewait.gif" id="i2"
    inlineStyle="width:214px;"/>
    <af:outputText value="... please wait" id="ot11"/>
    </af:panelGroupLayout>
    </af:dialog>
    </af:popup>
    Can any one please point me out where i am going wrong ?..
    -Thanks

    Do did not mention what went wrong or is not working.
    Have you tried the sample from the code corner page?
    Does this sample work? JDev version?
    Timo

Maybe you are looking for