HANDLE currentThreadHandle=GetCurrentThread ();
HANDLE currentProcessHandle=GetCurrentProcess ();
HANDLE realThreadHandle (0);
If (0==DuplicateHandle (currentProcessHandle, currentThreadHandle currentProcessHandle, & amp; RealThreadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
{
//If the function fails, the return value is zero
}
//...
//hung thread
SuspendThread (realThreadHandle);
//it throws an exception "used by the call to handle NtClose has NtSetInformationObject to prevent shut down,"
The CloseHandle (realThreadHandle);
CodePudding user response:
It is best to notify the thread after exit, then end of handle