This may be essentially the same thing Tim is suggesting, but you could set
a property on an associative array (Object) in the send function and delete
the corresponding property value in the result or fault handlers.  When
for..in returns zero iterations, all calls have returned.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Tim Rowe
Sent: Thursday, August 20, 2009 7:10 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] how to wait for more than one
httpserivice/remoteobject result to finish?

 

  

You don't really get much in the way of thread control in Flex, but a neater
way might still be to create something of a pseudo-barrier.

 

At the time each object is fired, you would also add a token to the barrier,
latching it and increasing the counter on that token.  Each event listener
could then call off to the barrier, passing the same token fired as a
property of the event to decrease against that token on the barrier - at the
point all tokens are unblocked (ie, reach 0) you can open the barrier.  Your
other code would sleep (I was almost going to say spinwait... hm, no :)
until the barrier is unlatched.

 

This could avoid you needing to write a handler for each event - the problem
with the below example is what happens when you need three, or four, of
seven events to be waited on.  Just something to give some thought to
anyway.

 

--Tim

 

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Wesley Acheson
Sent: Friday, 21 August 2009 5:20 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] how to wait for more than one
httpserivice/remoteobject result to finish?

  

private var list1Result:ResultEvent;
private var list2Result:ResultEvent;

private function handleList1Result(event:ResultEvent):void
{
  list1Result = event;
  if(list2Result)
  {
    handleResults(list1Result, list2Result);
  }
}

private function handleList2Result(event:ResultEvent):void
{
  list2Result = event;
  if(list1Result)
  {
    handleResults(list1Result, list2Result);
  }
}

private function handleResults(result1:ResultEvent,
result2:ResultEvent):void
{
  //your code here
}

On Thu, Aug 20, 2009 at 8:35 PM, coder3 <rrhu...@hotmail.
<mailto:rrhu...@hotmail.com> com> wrote:


Hi

my application needs to wait until two (or more) resultHandlers to get their
results and use them together.

for example,

<mx:RemoteObject id="myRO" destination="test" fault="FaultHandler(event)">
       <mx:method name="getList1"  result="handleList1Result(event)"/>
       <mx:method name="getList2"  result="handleList2Result(event)"/>
</mx:RemoteObject>

at application creationComplete, it calles myRO.getList1() and
myRO.getList2()

what can i do to make sure i get both results before i do anything else?

i know it can call myRO.getList1(), then in the
handleList1Result(event:ResultEvent), after it gets the list1 result, then
it calls myRO.getList2(),

but i would like to know a better, more clear way.

thanks

C

--
View this message in context: http://www.nabble.
<http://www.nabble.com/how-to-wait-for-more-than-one-httpserivice-remoteobje
ct-result-to-finish--tp25067471p25067471.html>
com/how-to-wait-for-more-than-one-httpserivice-remoteobject-result-to-finish
--tp25067471p25067471.html
Sent from the FlexCoders mailing list archive at Nabble.com.



------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: https://share.
<https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e6
2079f6847>
acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-
<http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo>
archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links


   (Yahoo! ID required)

   mailto:flexcoders-fullfeat
<mailto:flexcoders-fullfeatu...@yahoogroups.com> u...@yahoogroups.com


 


______________________________________________________________________
Notice: This email and attachments (if any) is for the exclusive use of the
addressee and may contain information that is privileged and confidential.
Any unauthorised use of the contents of the email and/or attachments is
expressly prohibited. If you are not the addressee of this email, please
notify me immediately by email and then immediately destroy any electronic
or paper copy of this email and/or attachments. Carsales.com Ltd and its
related companies do not accept responsibility for the views expressed in
the email or for the consequences of any computer viruses that may be
transmitted with this email. This email is subject to copyright. No part of
it should be reproduced, adapted or transmitted without the written consent
of the copyright owner.



Reply via email to