M
michaeltorus
Hi
If I start a bunch of asynchronous threads using a deletegate.beingInvoke, what is the prefered way to have the main thread wait until all threads have returned before continuing ...
I simply don't like the idea of an exmpty while loop, and even worse a while loop with a Thread.Sleep statement in it ....
At the moment I use a private int to count how many Threads I start, and decrement it each time a thread finishes (using locking of course) .... it all works fine but I just don't feel this is the best way to do it ....
I thought of using n event, but something still has to tell the main thread to wait until the event is fired ????
Thanks
Mike
If I start a bunch of asynchronous threads using a deletegate.beingInvoke, what is the prefered way to have the main thread wait until all threads have returned before continuing ...
I simply don't like the idea of an exmpty while loop, and even worse a while loop with a Thread.Sleep statement in it ....
At the moment I use a private int to count how many Threads I start, and decrement it each time a thread finishes (using locking of course) .... it all works fine but I just don't feel this is the best way to do it ....
I thought of using n event, but something still has to tell the main thread to wait until the event is fired ????
Thanks
Mike