how to know a bool array are all T/F

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created 5 threads to work in my program and I've also created a thread to monitor all 5 threads had still alive or not. Below is part of the monitor thread.


bool[] threadState;
threadState = new bool[num_thread];
threadState.Initialize();
do
{
if (threadState[] == true)
exitLoop = true;
for(int i=1; i <= num_thread;i++)
{
if (!td_work.IsAlive)
{
threadState = true;
}
}
}
while(exitLoop == false);

The question is how can I know the value of the bool array are all true instead of coding method by myself?
many thx~~~
 
You can probably achieve what you're trying to do using the
WaitHandle.WaitAll method, which waits for signals... each thread should be
signalled when it completes, so the method shoudln't return until all the
threads are complete.

--
John Wood
email: john dot wood at priorganize dot com

kelkel said:
I've created 5 threads to work in my program and I've also created a
thread to monitor all 5 threads had still alive or not. Below is part of the
monitor thread.
bool[] threadState;
threadState = new bool[num_thread];
threadState.Initialize();
do
{
if (threadState[] == true)
exitLoop = true;
for(int i=1; i <= num_thread;i++)
{
if (!td_work.IsAlive)
{
threadState = true;
}
}
}
while(exitLoop == false);

The question is how can I know the value of the bool array are all true

instead of coding method by myself?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top