C# 关闭窗体立即停止进程

C#在关闭窗体的时候,有时线程还在后台执行,没有及时退出。

处理方案:

为Form添加FormClosing事件,加入以下语句,在退出时,杀死本进程。

System.Diagnostics.Process.GetCurrentProcess().Kill(); 

很久没写WinForm啦 以后会用到!

原文地址:https://www.cnblogs.com/dachie/p/1820329.html