/// <summary>
        /// 窗口关闭删除所有活动线程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            System.Environment.Exit(0);
        }

在Form窗体右键->查看代码,添加以上代码,然后将该事件给FormClosing即可。

原因:只要有未结束的任务,即使关闭窗口,进程也不会结束。

因为我用到了线程,线程里面有while(true)任务,所以就无法结束进程。

参考网址:https://blog.csdn.net/yl2isoft/article/details/38168939

相关文章:

  • 2021-06-04
  • 2021-06-30
  • 2021-12-09
  • 2022-02-08
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-23
  • 2022-02-22
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案