在Visual Studio中关闭表单后,调试不会停止

san*_*p22 7 c# visual-studio-debugging

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

谢谢.

cod*_*der 6

这里试试这个

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)
}
Run Code Online (Sandbox Code Playgroud)

编辑:

如果有正在运行的infinite线程则执行

Thread myThread = new Thread(...);
myThread.IsBackground = true; //set your running thread to background
myThread.Start(...);
Run Code Online (Sandbox Code Playgroud)

你可以看到如何?从这里开始