[flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
Tracy, I was trying to illustrate what I had understood from what has been said: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. My example might not be the best but since the http.send() was in a function on its own, i.e a block, the server invocation will happen upon leaving that function. it is true that we are setting the responder right after that function call. But assuming that in my doit function I had: public function doit():void { callServer(); // do some other stuff callAnotherComputingAndStallingMethod(); // and now add the responder asyncToken.addResponder(...); } well, my chances for the server responding after I set the responder are slimmer. As in the other scenario where it's all in 1 method call, and the server call only gets invoked at the end of the method after I set the responder. Cheers, --- In flexcoders@yahoogroups.com, Tracy Spratt tr...@... wrote: .chances of it working are reduced. Why do you say that? Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Mehdi Sent: Wednesday, April 29, 2009 11:49 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How come setting the responder (async token) after the server call does WORKS??? I see. So shall I read your response as: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. So I were to have the following: var asyncToken:ASyncToken public function callServer():void { asyncToken= httpsrv.send(); } public function doit():void { callServer(); asyncToken.addResponder(...); } mx:button click=doit()/ So, in this case, my chances of it working are reduced... (not the 100% anymore). Is that right? thks. --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Adnan Doric astronaute@ wrote: The key word is asynchronous. httpsrv.send() is asynchronous so it gets executed after all synchronous statements (addResponder is synchronous) in the same block. cheers, Adnan --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Mehdi elextraana@ wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers
[flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
This is from a thread (sic) response from Seth Hodgson about a year ago... There is a single thread that advances through SWF frames and runs your ActionScript code and event handlers, but network calls are performed by separate background threads concurrently. In order to have calls processed concurrently on the server, they need to arrive as separate requests. In the case of AMF, if you make a series of calls quickly chances are good/excellent that the Player will batch them up and send them to the server in the body of a single HTTP POST. Thread is at http://tech.groups.yahoo.com/group/flexcoders/message/113808 --- In flexcoders@yahoogroups.com, Mehdi elextra...@... wrote: Tracy, I was trying to illustrate what I had understood from what has been said: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. My example might not be the best but since the http.send() was in a function on its own, i.e a block, the server invocation will happen upon leaving that function. it is true that we are setting the responder right after that function call. But assuming that in my doit function I had: public function doit():void { callServer(); // do some other stuff callAnotherComputingAndStallingMethod(); // and now add the responder asyncToken.addResponder(...); } well, my chances for the server responding after I set the responder are slimmer. As in the other scenario where it's all in 1 method call, and the server call only gets invoked at the end of the method after I set the responder. Cheers, --- In flexcoders@yahoogroups.com, Tracy Spratt tracy@ wrote: .chances of it working are reduced. Why do you say that? Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Mehdi Sent: Wednesday, April 29, 2009 11:49 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How come setting the responder (async token) after the server call does WORKS??? I see. So shall I read your response as: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. So I were to have the following: var asyncToken:ASyncToken public function callServer():void { asyncToken= httpsrv.send(); } public function doit():void { callServer(); asyncToken.addResponder(...); } mx:button click=doit()/ So, in this case, my chances of it working are reduced... (not the 100% anymore). Is that right? thks. --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Adnan Doric astronaute@ wrote: The key word is asynchronous. httpsrv.send() is asynchronous so it gets executed after all synchronous statements (addResponder is synchronous) in the same block. cheers, Adnan --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Mehdi elextraana@ wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers
[flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
The key word is asynchronous. httpsrv.send() is asynchronous so it gets executed after all synchronous statements (addResponder is synchronous) in the same block. cheers, Adnan --- In flexcoders@yahoogroups.com, Mehdi elextra...@... wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers
[flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
The service is invoked asynchronously so Flex just invokes the send and keeps executing. Unless the call to the service and its response is faster than the computer executing (read will never happen) then the responder will be added before the call returns. --- In flexcoders@yahoogroups.com, Mehdi elextra...@... wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers
[flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
I see. So shall I read your response as: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. So I were to have the following: var asyncToken:ASyncToken public function callServer():void { asyncToken= httpsrv.send(); } public function doit():void { callServer(); asyncToken.addResponder(...); } mx:button click=doit()/ So, in this case, my chances of it working are reduced... (not the 100% anymore). Is that right? thks. --- In flexcoders@yahoogroups.com, Adnan Doric astrona...@... wrote: The key word is asynchronous. httpsrv.send() is asynchronous so it gets executed after all synchronous statements (addResponder is synchronous) in the same block. cheers, Adnan --- In flexcoders@yahoogroups.com, Mehdi elextraana@ wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers
RE: [flexcoders] Re: How come setting the responder (async token) after the server call does WORKS???
.chances of it working are reduced. Why do you say that? Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Mehdi Sent: Wednesday, April 29, 2009 11:49 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How come setting the responder (async token) after the server call does WORKS??? I see. So shall I read your response as: Flex asynchronous methods get queued up and are only invoked once ALL synchronous calls in the same block get executed. So I were to have the following: var asyncToken:ASyncToken public function callServer():void { asyncToken= httpsrv.send(); } public function doit():void { callServer(); asyncToken.addResponder(...); } mx:button click=doit()/ So, in this case, my chances of it working are reduced... (not the 100% anymore). Is that right? thks. --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Adnan Doric astrona...@... wrote: The key word is asynchronous. httpsrv.send() is asynchronous so it gets executed after all synchronous statements (addResponder is synchronous) in the same block. cheers, Adnan --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, Mehdi elextraana@ wrote: This is a question that has been bothered me for some time. You know how in Flex you can invoke a service (say httpservice for instance) which returns a token. After that you set the responder on the token. I.e.: var asyncToken:ASyncToken = httpsrv.send(); asyncToken.addResponder(...) We set the responder/handler AFTER the call has been set. Its very awkward but it does work. I was hoping someone could explain this to me. Thank you. Flex being single threaded, the call to httpsrv.send() should actually invokes the server and not get into the second line about the responder until the call has been at least issued. But that's not how it works I guess. So, I am assuming the call is queued somewhere, untiluntil when??? Cheers