在 Visual Studio 中关闭表单后调试未停止 [英] Debug not stopping after form closing in Visual Studio

查看:37
本文介绍了在 Visual Studio 中关闭表单后调试未停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我关闭我用 C# 编写的表单时,Visual Studio 调试不会停止.关闭表单时如何停止调试过程.我在表单关闭事件中添加了 Application.Exit() 方法,但是没有用.

Visual Studio Debug does not stop when i close the form that i write in C#. How can i stop debug process when i close form. I added Application.Exit() method in the form closing event but it didn't work.

谢谢.

推荐答案

试试这个来自 这里

If (System.Windows.Forms.Application.MessageLoop)
{
  // Use this since we are a WinForms app
  System.Windows.Forms.Application.Exit()
}
Else
{
  // Use this since we are a console app
  System.Environment.Exit(1)
}

如果有运行 infinite 线程然后做

If there are running infinite threads then do

Thread myThread = new Thread(...);
myThread.IsBackground = true; //set your running thread to background
myThread.Start(...);

你能看到怎么做吗?从这里

And you can see how to? from here

这篇关于在 Visual Studio 中关闭表单后调试未停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆