Best approach to closing threads when user closes the form?

  • Thread starter Thread starter LordHog
  • Start date Start date
L

LordHog

Hello all,

I am a small application that I am developing which will use a few
threads. When the user closes the form the threads will remain present
until I close them. The Main Form instantiates a couple of
communications classes which contain the threads. So for this
communications class should I provide some sort of close/kill/terminate
method or should I provide a dispose() function to terminate the
threads? Thanks for any insight.

Mark
 
I am a small application that I am developing which will use a few
threads. When the user closes the form the threads will remain present
until I close them. The Main Form instantiates a couple of
communications classes which contain the threads. So for this
communications class should I provide some sort of close/kill/terminate
method or should I provide a dispose() function to terminate the
threads? Thanks for any insight.

See http://www.pobox.com/~skeet/csharp/threads/shutdown.shtml for how
to shut the threads down gracefully.

If the user closing the form will actually be the end of the app's
lifetime, and you don't care about how exactly those other threads shut
down, just make them background threads to start with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top