lecosson / assql

Automatically exported from code.google.com/p/assql
0 stars 0 forks source link

No mechanism to notify when an Asynchronous responder completes execution. #87

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Query database with select statement and add an Asynchronous responder to 
the MySql Token 
associated with that query.
2. Suppose this querying is an a function say queryDatabase() which retrieves 
amount field from 
database. And now I want to calculate the total of all these sums in  a 
separate function say 
calculateTotal().
3. So the function calls would be like

function queryDatabase():void
{
         ..
         ..

          token = statement.executeQuery("Select amount from ......");
          token.addResponder( new asynchronousResponder(

          function(data:Object,token:Object)
          {
                    resultSet = (ResultSet)data;
                    //Add all amounts into a Array. 
          } ,

          function(data:Object,token:Object)
          {
                    // Handle Error
          } ,

         token));

     function calculateTotal()
    {

            queryDatabase();

           // Calculate Sum here
   }          

 This is just a scenario which is describes the functionality I am looking for. 
What is the expected output? What do you see instead?
The function should calculate sum. But as an asynchronous responder is added, 
if 
calculateTotal() is called, the Array which stores the sum will not be 
populated with the result set 
and hence it is not possible to calculate the sum and the array length is found 
to be 0.

         How can i postpone the sum calculation and wait till the Array is populated i.e till the 
asynchronous responder populates the Array. Is it possible for the asynchronous 
responder to 
signal the completion of its execution and the function which calls it to wait 
for such a signal ?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by kashyap8...@gmail.com on 6 Sep 2009 at 1:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Is there ANY way of getting the query result SYNCHRONOUSLY? I'm new to AIR and 
AS... 
Are there threads or delays which I could use while waiting the result and 
checking 
the completion flag in a loop?

Original comment by 7mer...@gmail.com on 12 Mar 2010 at 4:53