4 Replies Latest reply on Oct 31, 2011 8:52 AM by Flex harUI

    Multi threading concept in flex?

    megharajdeepak Level 1

      Hello,

       

      I have an application with 4 quandrants. Each of it calls separate webservice and based on the result data that I get, I build the UI elements dynamically. Unfortunately, I have to wait for each of the result handler to finish building the UI. Is there a way to run all the 4 result handlers together?

       

      Ex:

      I have 4 webservices: ws1, ws2, ws3 and ws4. I pass some parameters and call these services, on creation complete:

      ws1.operationName.send();

      ws2.operationName.send();

      ws3.operationName.send();

      ws4.operationName.send();

       

      ws1ResultHandler(event:ResultEvent):void

      {

       

      }

       

      ws2ResultHandler(event:ResultEvent):void

      {

       

      }

       

      ws3ResultHandler(event:ResultEvent):void

      {

       

      }

       

      ws4ResultHandler(event:ResultEvent):void

      {

       

      }

       

      Based on which ever webservice operation's succeeds in getting the data first, that particular handler gets triggered. Once all the code in this handler is executed, it then gets into the next webservice operation's result handler.

       

      Is there a way, to trigger all these handlers together and build the UI elements together dynamically at a time?

      Appreciate your insights on this.

        • 1. Re: Multi threading concept in flex?
          pauland Level 4

          "Is there a way, to trigger all these handlers together and build the UI elements together dynamically at THE SAME time?"

           

          Excuse my little edit, but the answer is "no". Flex is not multi-threaded.

           

          You may wish to look at why it takes so long to build the UI that this is an issue.

          • 2. Re: Multi threading concept in flex?
            megharajdeepak Level 1

            Ohh! Doesn't sound good to me

             

            Well, the problem is that the data set is very huge. Each quadrant takes about 30 seconds to load and build the UI. I was wondering if I could trigger all those result handlers together at the same time, then I could load and build all 4 quandrants UI in just 30 seconds, instead of 30*4 = 120 seconds, which is what is happening right now.

            • 3. Re: Multi threading concept in flex?
              pauland Level 4

              It's not Flex that's the problem, it's the huge amount of data. Look at ways to either page that data or build the interface before all of the data has loaded. Try and keep the client lightweight.

              1 person found this helpful
              • 4. Re: Multi threading concept in flex?
                Flex harUI Adobe Employee

                Threading probably wouldn’t help here (and would probably make things worse).  If you are creating lots of UI widgets, the CPU is already fully occupied.  Adding thread switching overhead would just eat up more CPU cycles.  Threading helps when a process is blocked on something like getting data off a disk, but I doubt that is the case here.  I suggest trying to find out ways to create the individual quadrants more quickly by deferring instantiation of widgets until you need them.

                1 person found this helpful