Is the Terminate­Thread function synchronous?

Raymond Chen

Raymond

A customer wanted to know whether the Terminate­Thread function was synchronous. In other words, does the Terminate­Thread function wait until the target thread has definitely terminated before returning?

No. The Terminate­Thread function queues a termination to the target thread but does not wait for confirmation that the termination has occurred.

If you want to wait until the target thread has definitely terminated, wait for the thread object to become singnaled, say by calling Wait­For­Single­Object.

But please, stop calling Terminate­Thread. There are no valid use cases for it. Any time you call it, you will corrupt the target process, so you may as well just terminate the entire process and be done with it.

Raymond Chen
Raymond Chen

Follow Raymond   

0 comments

Comments are closed.