[Gc] Attaching and dettaching existing threads

Julian Hall jules@acris.co.uk
Tue, 14 Oct 2003 10:14:17 +0100

David Bakin wrote:

>On Windows a DLL does not get notified (via DLL_THREAD_ATTACH) of threads
>existing before the DLL was loaded - except for the thread loading the DLL
>(which call DLLMain with parameter DLL_PROCESS_ATTACH).  It also doesn't get
>notified for each thread when the process (only for the thread that is
>actually calling ExitProcess) or for threads that are TerminateThread'.
This is  actually a point I wanted to raise a while ago, but neglected 
to do so.  I have  a Win32 program that uses TerminateThread to cancel a 
background operation if it is taking too long.  This generally  causes a 
crash in the collector, presumably because it is  accessing  the 
thread's stack which no longer exists.  Is there any way of avoiding 
this problem?