Thread completed state.

O

objectref

Hi,

is there a way to spawn some threads (not from the thread pool) and knowing
when each of these therads has completed its' job ?

I have thought to put them on a hash and requery their IsAlive or
ThreadState status
but is it another way to do so ?

thanks in advance,

objectref
 
V

Vadym Stetsyak

You can create an array of Events and when the thread proc is completed the
event is signaled you can use WaitAny and then from the return value you can
determine which thread has finished its job.

You are not restricted to events here, mutex can also be used.

The whole algorithm would be like this
thread starts a number of threads each thread aquires an mutex or sets an
event from the array. Then main thread calls in the loop WaitAny and
determines which one of the threads is finished.
 

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

Top