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
  • 68,786
  • 25
  • 88
  • 134
matt-pielat
  • 1,489
  • 3
  • 17
  • 32
  • 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
  • 897,808
  • 140
  • 1,634
  • 2,455