This looks like a bug to me, but the MSDN looks a little ambiguous to me.
I found some code that does this:
Code:
HANDLE hTcpResponder = CreateThread( NULL, 0, TcpResponder, &ServiceInfo, 0, &TcpResponderId );
if ( hTcpResponder == NULL )
{
emsg( SPNorm, "New Tcp Responder Did not Start" );
}
else
{
CloseHandle( hTcpResponder );
}
According to the MSDN:
Originally Posted by
MSDN
The thread object remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle.
Does that mean that you should close the handle AFTER the thread has finished, or can you close it while the thread is still running and then you don't have to worry about when the thread finishes?
I thought closing the handle would end the thread?