Quantcast
Channel: The Old New Thing
Viewing all articles
Browse latest Browse all 3085

Is the Terminate­Thread function synchronous?

$
0
0

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.


Viewing all articles
Browse latest Browse all 3085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>