$ npm install async

var async = require('async');

async.parallel({
  first: function(callback) {
    // do something
    callback(null, result);
  }
  second: function(callback) {
    // do something
    callback(null, result);
  }
}, function(err, results) {
  console.log('both done!');
  console.log(results.first);
  console.log(result.second);
});

This is one of many libraries dealing with this. Documentation here 
https://github.com/caolan/async

On Wednesday, 18 August 2010 09:37:48 UTC+2, Surendra Singhi wrote:
>
> Hi,
>
> I am trying to use nodejs in one of my projects, and I have a
> requirement that the main thread needs to wait for couple of unrelated
> asynchronous tasks to finish.
> Here is what I want,
>     t1 = async task
>     t2 = another async task
>     wait for t1 & t2 to finish
>
> I am not able to find a way to do it, or even a pattern suggesting
> this kind of usage.
> How can this be done?
>
> Thanks!
> -- 
> Surendra Singhi
> http://www.kreeti.com
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to