Home > Software engineering >  About the thread abort and initialization
About the thread abort and initialization

Time:11-14

Excuse me, waiting for the signal in a worker thread function, if due to force majeure factors (such as external equipment suddenly loses power), receiving less than the semaphore, so how to err on the side of the termination of the thread in the main process?

UINT ThreadProc ()
{
.
The WaitForSingleObject (mThreadEventDead, INFINITE);//wait event trigger
.
return 0;
}

CodePudding user response:

Can bring INFINITE change as the time, it doesn't have been waiting for, check the return value, and determined the trigger or timeout, so, will have the opportunity through global variables, such as simple method,
  • Related