|
-
Dec 5th, 2010, 08:23 AM
#3
Re: Closing threads on Application Exit?
 Originally Posted by stlaural
And Yes, once the main thread is killed, the threads its started a supposed to be killed too.
That's not quite true. A thread can be either a foreground thread or a background thread. The one and only difference is that background threads are terminated when the application exits and foreground threads aren't. If you're using BackgroundWorkers then you're using background threads. If you want your worker threads to be terminated automatically then that's fine. If you want to be able to cleanup first, you should explicitly create your own Thread objects and don't set their IsBackground property to True. That way, you can set a flag or the like from the UI thread and then call Application.Exit, but each worker thread will have the chance to perform its own cleanup before terminating.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|