P
Peter Kirk
Hi there
I am looking at using a thread-pool, for example one written by Jon Skeet
(http://www.yoda.arachsys.com/csharp/miscutil/). Can anyone tell me if this
pool provides the possibility to wait for all its threads to finish?
For example, if I start 20 threads:
CustomThreadPool pool = new CustomThreadPool("PetersThreadPool");
ThreadMethod m = new ThreadMethod(InsertThread);
for (int i = 0; i < 20; i++)
{
pool.AddWorkItem(m, i);
}
[
where my thread method is:
delegate object ThreadMethod(int val);
private object InsertThread(int val)
{
Console.WriteLine("Thread " + val);
return 0;
}
]
How do I wait until all the threads are finished, before my program should
continue? Do I do this here:
while (pool.WorkingThreads > 0)
{
}
Thanks,
Peter
I am looking at using a thread-pool, for example one written by Jon Skeet
(http://www.yoda.arachsys.com/csharp/miscutil/). Can anyone tell me if this
pool provides the possibility to wait for all its threads to finish?
For example, if I start 20 threads:
CustomThreadPool pool = new CustomThreadPool("PetersThreadPool");
ThreadMethod m = new ThreadMethod(InsertThread);
for (int i = 0; i < 20; i++)
{
pool.AddWorkItem(m, i);
}
[
where my thread method is:
delegate object ThreadMethod(int val);
private object InsertThread(int val)
{
Console.WriteLine("Thread " + val);
return 0;
}
]
How do I wait until all the threads are finished, before my program should
continue? Do I do this here:
while (pool.WorkingThreads > 0)
{
}
Thanks,
Peter