Because when shutdown, threads may have begun to Sleep, and the computer shutdown process will not wait for you after this thread, so lead to the back of the code is not performed, do you have a solution?
CodePudding user response:
Threads do not use the Sleep functionCodePudding user response:
Unwrapped Sleep for 2 seconds to execute, judge markDWORD dwOut=GetTickCount () + 2000.
While ((! BExitFlag) & amp; & The GetTickCount () & lt; DwOut)
{
Sleep (1);
}
CodePudding user response:
Don't Sleep, for 1 second with a timeout WaitForSingleObjectSo you can set the signal at any time in the main thread wait to finish it,
CodePudding user response: