I have a method that calls two services from PHP at the same time. Due to multi-tasking abilities of Flex, I think that each service is called in a different thread.
My problem is: Both services return an Array of Objects from the database. But the second service will feed a DataGrid that has a handler for each record. This handler will compare that from both Arrays and when Flex finishes the second one before finishes the first one, I have a problem because the handler tries to compare data with a null object (the PHP Service didn't respond yet).
Any ideas?
EDIT:
On the day that I posted this question, some guy gave me an amazing idea, but sadly seems like he deleted his post, I don't know why. I kept his idea on my mind and I found a solution that fits my design pattern with his idea.
He told me to put a flag telling me if the data was already loaded or not. So here is what I'm doing now: I call first service; I call second service;
On the result of first service, I check the Flag on the second service, if it's true, it means that it was already loaded, so I can just store my data in the DataGrid so the handler can be called. If the flag is false, it means that the second data wasn't loaded yet, so instead of storage the data in the official dataProvider, I storage it on a _temp DataProvider that is not BOUND to the dataGrid. In this case, when the second data is loaded, a listener event is dispatched to the first service telling him to catch the _temp dataProvider and copy that to the official dataProvider.
Particularly, I liked the solution and it doesn't break the Table Data Gateway design pattern.
Thanks everyone for the help.