Login  Register

Re: How to kill an overlapped thread ?

Posted by Bernhard Kohlhaas-7 on Mar 04, 2005; 11:03pm
URL: https://forum.world.st/How-to-kill-an-overlapped-thread-tp3373253p3373317.html

Blair McGlashan wrote:
>
> And I have to tell you that it does. At least if does if you include the
> FILE_FLAG_OVERLAPPED flag when opening the directory handle, otherwise
> attempting to close it will indeed block.

Hi Blair,

You are right of course, I didn't use the FILE_FLAG_OVERLAPPED flag.
Thank you for trying this. :)

I noticed two other things:

- When you close the file handle, while the call to
ReadDirectoryChangesW is "unblocked", so the Smalltalk process can end
in a graceful way. That comes in very handy.

- A strange thing is that, when a file event actually happens and
   the forked process ends, before closing the handle an twofold
   evaluation of "KernelLibrary default closeHandle: handle"
   will answer "true" the 2nd time as well (at least if the 2nd
   eveluation is within a few seconds of the 1st).
   Perhaps just another Windows oddity.

> As MSDN makes very clear, calling TerminateThread is a bad idea in a process
> that you wish to keep running.

And since now the thread is unblocked when closing the handle, there is
no need to kill it in the first place.

Best Regards,
Bernhard