Re: AfxBeginThread on each user action X or re-use same thread (w



> First the easy part. The m_hThread public member of the class is a handle to
> the underlying Win32 thread. Thread handles are synchronization objects and
> when they are "signaled" the thread is done. You can test the handle with
> any of the wait functions using a timeout of zero to determine if the thread
> has exited or not.
>
> As for the question as to best practice - it is trite to say but the number
> you need depends on how you intend to use them. If just one will do, don't
> create more. And no matter what compiler you use, you will find thread pool
> support in Win32 on 2K/XP and 2K+3.
>
> Regards,
> Will
So i guess you guys recommend re-using the same thread then, and making a
new one only when the thread unexpectedly dies, if ever?
What i had in mind for re-use is:
while (true) {
wait for signal (this will be signaled every time a secondary window
is closed)
run method when signaled
}
But most importantly, will an unexpected termination, such as due to an
uncaught exception, be handled this way as well?

P.S. What is the API that could be used for thread pool in VC 6.0 (no .Net
allowed)?

Thanks.
.


Loading