How to Kill Thread in C#?

后端 未结 1 1348
梦如初夏
梦如初夏 2021-01-15 02:55

I have a thread that opens a form of type MyMessageAlert. This form is a popup window that is opened when I call it. It has a timer which calls a method CloseWindow() after

相关标签:
1条回答
  • 2021-01-15 03:20

    Maybe you want to use Background-Threads instead of Foreground-Threads. Your application start with at least one Foreground-Thread (main process thread). If you create new Threads using the Thread-class directly (e. g. new Thread(...)), this will be an foreground thread.

    An AppDomain is not unloaded when at least one foreground thread is still running. To avoid this behavior you can create a background thread. Typically you use background threads from the ThreadPool-class, or by setting the IsBackground-Property at the thread object directly.

    edit: An short explanation at the MSDN.

    0 讨论(0)
提交回复
热议问题