A
Abubakar
Hi,
from msdn: "Closing a thread handle does not terminate the associated
thread. To remove a thread object, you must terminate the thread, then close
all handles to the thread."
Through the documentation it seems that the thread proc must be exited
*first* and than the CloseHandle should be called on its handle. My problem
is that my threads will exit whenever they want without notifying any other
part of my code. So who will take care of closing their handles? For this
reason I have written the code in such a way that the threads close their
own handle just before they r about to exit from their thread proc. For
example here is what my code looks like.
class anyclass
{
//some where up here is HANDLE m_threadhandle; which contains a valid thread
handle
......
anyclass::thread_proc()
{
// thread functionality here
...
// on the last line before exiting:
CloseHandle( m_threadhandle );
}
}
Is this ok?
Regards,
Ab.
from msdn: "Closing a thread handle does not terminate the associated
thread. To remove a thread object, you must terminate the thread, then close
all handles to the thread."
Through the documentation it seems that the thread proc must be exited
*first* and than the CloseHandle should be called on its handle. My problem
is that my threads will exit whenever they want without notifying any other
part of my code. So who will take care of closing their handles? For this
reason I have written the code in such a way that the threads close their
own handle just before they r about to exit from their thread proc. For
example here is what my code looks like.
class anyclass
{
//some where up here is HANDLE m_threadhandle; which contains a valid thread
handle
......
anyclass::thread_proc()
{
// thread functionality here
...
// on the last line before exiting:
CloseHandle( m_threadhandle );
}
}
Is this ok?
Regards,
Ab.