附加Visual Studio调试器会导致高CPU使用率和UI线程锁 [英] Attaching Visual Studio debugger causes high CPU usage and UI thread locks
问题描述
CPU使用率模式下的VS分析器显示CPU被[外部代码]
如何解决此问题?
如果你只是抛出异常,你真的如何处理这个异常?
例如,如果客户端将请求发送到服务器端,并且服务器端向客户端发出响应,但是您的客户端无法真正处理某些异常的响应,我认为这会影响您的UI过程可能具有高CPU使用率或其他。
所以真正的原因是异常是什么,以及如何真正解决/处理这个异常。
为了避免看到消息,右键单击输出窗口并取消选中异常消息是一种解决方法,但找到真正的原因并解决它会更好解决方案。
I have a WPF app that does some async networking (negotiation over 100 sockets in parallel). If I launch app with VS debugger attached and start networking code my CPU usage jumps to 60% (shared between VS, VS debugger and vshost processes) and UI becomes very unresponsive with constant freezes up to 3 seconds. The same happens when I attach a debugger to already running process. Under normal conditions it uses 1-3% CPU and UI is smooth.
VS profiler in "CPU usage" mode shows that CPU is used by [External code]
How do I troubleshoot this issue?
If you just throw the Exception, how did you really handle this Exception?
For example, if the client sends the requests to the server side, and server side gives the responses to the client, but your client can't really handle the response with some Exceptions, I think it would impact your UI process which may have high CPU usage or others.
So the real cause is that what the Exception is and how to really resolve/handle this Exception.
To avoid seeing that messages, right-click on the output window and uncheck "Exception Messages" is a workaround, but find the real reason and resolve it would be a better solution.
这篇关于附加Visual Studio调试器会导致高CPU使用率和UI线程锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!