Threads dying prematurely.

  • Thread starter Thread starter Dave Rudolf
  • Start date Start date
D

Dave Rudolf

Hi all.

I have a multithreaded little app that I am writing. Periodically, I see
messages on my console that read:



The thread '<No Name>' (0xa7c) has exited with code 0 (0x0).



Wheever I see this message, my threads appear to be dying prematurely,
althogh I am not calling Abort() or Suspend(). Also, if I put a try-catch
around the threaded code, I receive no exception. Any idea what could cause
such a thing?



Thanks,



Dave.
 
The method the thread was called to run returned. Put a Console.Writeline
message before the method exists and inside your loops to track down why
(i.e. state change, eof, etc.)
 
be sure you have plenty of error handling in your threaded functions. If an
unhandled exception occurs in a thread other than the main one, the thread
will simply exit without any kind of error message or something to let you
know that an exception occurred.

Chris
 
You will see a lot of those if you are using classes that use the
threadpool, such as web services or network functions - as threadpool
threads die you will see that notification.

If you create your own threads you can name (Thread.Name) each one when you
create it so you can easily tell the difference between your threads and
system threads. If they are your threads that are terminating then you need
to figure out why.
 
I have a try-catch around the whole method that is getting called by the
ThreadStart.
 
Back
Top