2013-07-19 24 views
0

当使用F4分离VS调试器(又名:停止调试)时,VS调试器是否会引发一些可以在C++或C#应用程序中捕获的信号或异常?同样的问题,虽然对我来说不太重要,但我认为可以通过在C++中使用单独的线程IsDebuggerPresent来解决这个问题。当调试器分离时,应用程序能够得到通知吗?

+1

据我所知,调试器不“自我宣告”。 –

回答

1

没有从Visual Studio发送的事件。但你可以这样模拟:

 var t = new Thread(new ThreadStart(() => 
     { 
     while (true) 
     { 
      if (!Debugger.IsAttached) 
      { 
      //Check if the IsAttached Changed raise a custom event DebuggerDetached 
      } 
      else 
      { 
      //Check if the IsAttached Changed raise a custom event DebuggerAttached 
      } 

      Thread.Sleep(100); 
     } 
     })); 

     t.Start(); 
+0

搜索了一些,实际上找不到事件或任何地方,所以像这样的解决方案是唯一的选择。 – stijn

相关问题