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:
CustomThreadPoo l pool = new CustomThreadPoo l("PetersThread Pool");
ThreadMethod m = new ThreadMethod(In sertThread);
for (int i = 0; i < 20; i++)
{
pool.AddWorkIte m(m, i);
}
[
where my thread method is:
delegate object ThreadMethod(in t val);
private object InsertThread(in t val)
{
Console.WriteLi ne("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.WorkingTh reads > 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:
CustomThreadPoo l pool = new CustomThreadPoo l("PetersThread Pool");
ThreadMethod m = new ThreadMethod(In sertThread);
for (int i = 0; i < 20; i++)
{
pool.AddWorkIte m(m, i);
}
[
where my thread method is:
delegate object ThreadMethod(in t val);
private object InsertThread(in t val)
{
Console.WriteLi ne("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.WorkingTh reads > 0)
{
}
Thanks,
Peter
Comment