RE: [flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-10 Thread Tracy Spratt
[mailto:[EMAIL PROTECTED] On Behalf Of robbarreca Sent: Monday, June 09, 2008 5:48 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Attaching custom data to events (while avoiding race condition) So when I say thread maybe I'm using the wrong terminology. I'm not actually talking about

[flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-10 Thread robbarreca
[mailto:[EMAIL PROTECTED] On Behalf Of robbarreca Sent: Monday, June 09, 2008 5:48 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Attaching custom data to events (while avoiding race condition) So when I say thread maybe I'm using the wrong terminology. I'm not actually talking

[flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread robbarreca
Sorry, I must have not explained well. The race condition I'm talking about exists here: thread 1: calls load() and say someFlag gets set to 1; thread 2: calls load() and someFlag is set to 2; thread 1: the first load is complete and handleComplete() is called, but someFlag is set to 2 when the

Re: [flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread Daniel Gold
It makes sense when dealing with concurrent programming, but Flash is single threaded and you won't have a case where multiple threads are task switching and simultaneously executing functions. Every function call and event handler in flex is basically in-lined and will execute to completion. On

[flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread robbarreca
So when I say thread maybe I'm using the wrong terminology. I'm not actually talking about two different users/browsers. I'm talking about the same browser running two calls of load(). Let me expand: function onInitialize() { loader.addEventListener(handleComplete); load(1); // Say this

[flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread robbarreca
I'd love to know if my explanation made any sense when someone gets a free moment. If it sounds like I'm smoking crack, please let me know and I'll check myself into rehab. Thanks! -R --- In flexcoders@yahoogroups.com, robbarreca [EMAIL PROTECTED] wrote: So when I say thread maybe I'm using

Re: [flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread Josh McDonald
If you need responses to come back in order, don't make the second request until you've got the first result. Or wait for all responses, and put them in an array based on some order-information in the AsyncTokens. -Josh On Tue, Jun 10, 2008 at 11:48 AM, robbarreca [EMAIL PROTECTED] wrote:

Re: [flexcoders] Re: Attaching custom data to events (while avoiding race condition)

2008-06-09 Thread Daniel Gold
I think the piece that you were missing is that load is actually pulling data in from a service, and you can't rely on the order in which the service responses return. Josh's answer above is definitely a best practice, if you have multiple service calls that need to have responses handled in a