2

Well, should I? Assume that the child thread doesn't have to perform any sort of cleanup and can be terminated at any point.

    private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
        MyThread.Abort();
        MyThread.Join();
    }
nvoigt
  • 75,013
  • 26
  • 93
  • 142
matt-pielat
  • 1,659
  • 3
  • 20
  • 33
  • 2
    http://stackoverflow.com/questions/3542061/how-do-i-stop-a-thread-when-my-winform-application-closes – Habib Oct 15 '14 at 17:12

1 Answers1

2

No, the CLR already aborts it, assuming you've set its IsBackground to true. You doing it yourself is slightly riskier, the CLR uses a bigger hammer to stop it. Thread.Abort() can be ignored or cause the thread to fumble when it sees the ThreadAbortException, the CLR uses a rude abort that cannot be observed.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536