A customer wanted to know whether the
TerminateThread
function was synchronous.
In other words, does the
TerminateThread
function
wait until the target thread has definitely terminated
before returning?
No.
The TerminateThread
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
WaitForSingleObject
.
But please,
stop calling TerminateThread
.
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.