|We don't bite newbies here... much|
Is it OK with “Sleep(0)”, or must it be a non zero parameter value?
The problem here is the assumption that yielding the processor will ensure that the terminated thread has had time to fully clean up before this thread will get another timeslice and exit. If the system is busy, many other threads in the system are eligible to run -- especially if they are higher priority -- then the callee of TerminateThread() might easily get several timeslices before the thread actually ends.
The correct (or maybe just better) thing to do, would be to pass a known exit code value on the TerminateThread() call and then loop checking the thread exit code until it returns that value rather than STILL_ACTIVE. Eg. Something like this:
Once GetExitCodeThread() returns the known value, you should be pretty certain that the thread has actually terminated.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.