RE: [flexcoders] how to wait for more than one httpserivice/remoteobject result to finish?
Tim makes a great point... Events are great for tracking things, but you also have to be careful not to have too many events waiting in your program. I have seen cases where there are so many events waiting in a program that weird things happen with them like the handler not getting the message that an even has fired. If you're doing just a few events then you shouldn't have that big of a deal. I try to keep my active events low and around 10-15 so that older and slow computers shouldn't have a problem. From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Tim Rowe Sent: Thursday, August 20, 2009 6: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 mailto:rrhu...@hotmail.com> > wrote: Hi my application needs to wait until two (or more) resultHandlers to get their results and use them together. for example, 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.com/how-to-wait-for-more-than-one-httpserivice-remoteo bject-result-to-finish--tp25067471p25067471.html <http://www.nabble.com/how-to-wait-for-more-than-one-httpserivice-remote object-result-to-finish--tp25067471p25067471.html> Sent from the FlexCoders mailing list archive at Nabble.com. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf- 1e62079f6847 <https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf -1e62079f6847> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo <http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo> ! Groups Links (Yahoo! ID required) mailto:flexcoders-fullfeatu...@yahoogroups.com <mailto:flexcoders-fullfeatu...@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 co
RE: [flexcoders] how to wait for more than one httpserivice/remoteobject result to finish?
The data gets populated/manipulated in the result="...". If the data doesn't come in for some reason, the fault handler kicks in. You can pass customized values into the fault handler from your RDO as well. So, if your handleList1Result(event) function fires, then it has data. Then you can check for individual variables within that data set to make sure you have everything... From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of coder3 Sent: Thursday, August 20, 2009 1:36 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] how to wait for more than one httpserivice/remoteobject result to finish? Hi my application needs to wait until two (or more) resultHandlers to get their results and use them together. for example, 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.com/how-to-wait-for-more-than-one-httpserivice-remoteo bject-result-to-finish--tp25067471p25067471.html <http://www.nabble.com/how-to-wait-for-more-than-one-httpserivice-remote object-result-to-finish--tp25067471p25067471.html> Sent from the FlexCoders mailing list archive at Nabble.com. -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean.
RE: [flexcoders] how to wait for more than one httpserivice/remoteobject result to finish?
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 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, 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.
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 mailto:rrhu...@hotmail.com>> wrote: Hi my application needs to wait until two (or more) resultHandlers to get their results and use them together. for example, 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.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.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links __ 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.
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 wrote: > > Hi > > my application needs to wait until two (or more) resultHandlers to get > their > results and use them together. > > for example, > > > > > > > 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.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.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > >
[flexcoders] how to wait for more than one httpserivice/remoteobject result to finish?
Hi my application needs to wait until two (or more) resultHandlers to get their results and use them together. for example, 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.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.