0 Replies Latest reply on Jan 12, 2011 1:30 PM by billsalias

    How to delay a long running tasks start until display is updated?

    billsalias

      I am having a problem in that a progress bar I want to use to show progress of a long running background process is not showing up for a long time (up to 10 seconds) after the long running process is started. This is in an AIR application and the background process is an external native process, so once it is launched the UI thread is free to run, but the launch of the process can take time.

       

      Below is the current state of the relevant code.

       

      In addition to the current format I have also tried using the CREATION_COMPLETE, EXIT_FRAME and RENDER events with the same results.

       

      If I up the value in setTimeout to 500ms the progress bar displays quickly, but I would prefer to not delay the launch of the background process for no reason.

       

      If I comment out the loadPorject call the progress bar is displayed instantly.

       

      Any help is appreciated.

       

      private function continueLoad(evt:Event):void

      {

           ...

           // We are about to start some potentially long running process

           CursorManager.setBusyCursor();

       

       

           curPopup = new SyncProgress();

           curPopup.addEventListener(Event.ENTER_FRAME, popupLoadedHandler);

           PopUpManager.addPopUp(curPopup, parentView, true);

           PopUpManager.centerPopUp(curPopup);

           curPopup.stage.invalidate();

      }

       

      private function popupLoadedHandler(event:Event):void

      {

           curPopup.removeEventListener(Event.ENTER_FRAME, popupLoadedHandler);

           setTimeout(function():void{syncManager.loadProject(mainViewModel.selectedUserItem.id,proj ectFile.nativePath,overwrite);},0);

      }