在 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