Thread Detach Notification

  • Thread starter Thread starter Majid
  • Start date Start date
M

Majid

Hi,

Is there a way in managed .NET to get a notification as to when a
thread exits normally? In the unmanaged world, you could handle the
DLL_THREAD_DETACH in DllMain( ), but I couldn't find anything in .NET
that gives you this notification. I could iterate through the list of
available threads in the process to find if a particular thread Id is
still alive, but that would not work for my implemenation. Thanks.
 
I'd try using a semaphore to signal when a thread ends. Or you might call a
function when your thread ends. (see Interlocked, lock{}, Mutex,
ThreadAbortException; all can be found in System.Threading)

HTH,
Axel Dahmen
 
On the thread variable, you can use the join method.

dim MyThread as Thread
MyThread = new Thread(mythreadsub)
MyThread.Start

MyThread.Join ' Wait for MyThread to complete.

Mike.
 
Back
Top