C# Improvement on a Fire-and-Forget

Posted by adam on Stack Overflow See other posts from Stack Overflow or by adam
Published on 2010-03-31T14:46:05Z Indexed on 2010/03/31 14:53 UTC
Read the original article Hit count: 505

Filed under:
|
|

Greetings

I have a program that creates multiples instances of a class, runs the same long-running Update method on all instances and waits for completion. I'm following Kev's approach from this question of adding the Update to ThreadPool.QueueUserWorkItem.

In the main prog., I'm sleeping for a few minutes and checking a Boolean in the last child to see if done

while(!child[child.Length-1].isFinished){
Thread.Sleep(...);
}

This solution is working the way I want, but is there a better way to do this? Both for the independent instances and checking if all work is done.

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about fire-and-forget