Home All Groups Group Topic Archive Search About

Thread state after it's initiator exits.

Author
16 Jan 2006 11:01 PM
Feng
My main program starts a thread. My question is what happens to the thread
when the main program goes away? Does the thread exits automaticly with the
main, or does the main program need to make sure that it stops the thread
before it terminating itself?

Thanks.

Feng

Author
16 Jan 2006 11:12 PM
Armin Zingler
"Feng" <F***@discussions.microsoft.com> schrieb
> My main program starts a thread. My question is what happens to the
> thread when the main program goes away? Does the thread exits
> automaticly with the main, or does the main program need to make
> sure that it stops the thread before it terminating itself?


Why not try it? :-)

Unless the new thread is not a background thread (t.IsBackground = True),
the process does not exit before all threads exited.

Details:
http://msdn.microsoft.com/library/en-us/dllproc/base/terminating_a_process.asp


Armin