Login  Register

Re: How to kill an overlapped thread ?

Posted by Bernhard Kohlhaas-7 on Feb 25, 2005; 12:44am
URL: https://forum.world.st/How-to-kill-an-overlapped-thread-tp3373253p3373257.html

maurel wrote:
> From Dolphin I am calling an external dll, I am using the overlap
> mechanism
> because the call returns in 10 mins.
>
> Is there a way to stop such a call while it is executing ? perhaps by
> killing
> the overlapped thread  ?

I haven't found one, even Process>>kill doesn't terminate the OS thread
in my case, an overlapped call to WinAPI function ReadDirectoryChangesW.
Since this function monitors certain events in the file system, i.e. a
file was created, I am creating such an event myself by creating a
temporary file (and subsequently deleting it). This way the API call
returns and the forked Smalltalk process can detect the termination
condition and end itself.

It's not pretty and it has some drawbacks, i.e. if the user doesn't have
write-permission, but it's currently the only solution I found for this
problem. Perhaps something similar might work in your case.

> I read in the Dolphin Education center that the threads used to perform
> overlapped calls are maintained in a pool.
> How can I get a reference to that pool ?

I doubt that this would be appropriate, since the Smalltalk process that
initiated the overlapped call would be in an undefined state, if the
OS thread was killed. What I'd like to see is, that terminating or
killing a Smalltalk process would automatically and immediately kill all
overlapped OS threads. I don't know though who's to blame in my case,
Dolphin or Windows itself.

Best Regards,
Bernhard