6 Replies Latest reply on Apr 13, 2011 12:09 PM by timatlanta

    Confirmation on understaning of flex single-threaded with async result handlers?

    rickcr Level 1

      I'm pretty sure I understand this correctly but want to be certain:

       

      Even if you have two or more result handlers in a class that are handlers for async calls (http service calls), any given result handler will fully complete before another handler will begin executing (due to the single threaded nature of flash.)

       

      So for example if you have:

       

      var flag:Boolean = true;

       

      function handlerOne(event:ResultEvent):void {

             if (flag) flag = false

      }

       

      function handlerTwo(event:ResultEvent):void {

            if (flag) flag = false

      }

       

      Is it guaranteed that whichever handler is called first, that its method body will completely finish before the other handler runs?

       

      I don't want a case where it's theoretically possible that you could evaluate "flag" as true even though a split fraction of a second later it was really set to false by the other handler.  I do not believe this could happen since I'm pretty sure flash is all single threaded (otherwise you'd need to provide some kind of 'synchronizing' functionality.)