On Aug 22, 1:01 pm, "Brian Stoop" <b.st...@consul tant-spam.free.com>
wrote:
A simple way could be to keep a static counter which can be updated in
the call back function "TestThread 1". Make the main thread wait while
this counter is not maxed out; 10 in your case.
wrote:
I have several Threads that start other Threads like this:
>
ThreadA
{
for (int i=0; i <10; i++)
{
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(Te stThread1),
(object)i);
}
>
// Wait for all TestThread1 to terminate before proceeding ??????
>
}
>
ThreadB
{
for (int i=0; i <10; i++)
{
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(Te stThread2),
(object)i);
}
>
// Wait for all TestThread2 to terminate before proceeding ??????
>
}
>
--------------------------------------------------------------------------------------------------
>
The TestThread1 and TestThead2 methods have as a randon sleep up to 30
seconds before terminating.
>
How can I tell when all the ThreadA ThreadPool requests have completed ?
>
thanks B
>
ThreadA
{
for (int i=0; i <10; i++)
{
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(Te stThread1),
(object)i);
}
>
// Wait for all TestThread1 to terminate before proceeding ??????
>
}
>
ThreadB
{
for (int i=0; i <10; i++)
{
ThreadPool.Queu eUserWorkItem(n ew WaitCallback(Te stThread2),
(object)i);
}
>
// Wait for all TestThread2 to terminate before proceeding ??????
>
}
>
--------------------------------------------------------------------------------------------------
>
The TestThread1 and TestThead2 methods have as a randon sleep up to 30
seconds before terminating.
>
How can I tell when all the ThreadA ThreadPool requests have completed ?
>
thanks B
the call back function "TestThread 1". Make the main thread wait while
this counter is not maxed out; 10 in your case.
Comment