附加Visual Studio调试器会导致高CPU使用率和UI线程锁 [英] Attaching Visual Studio debugger causes high CPU usage and UI thread locks

查看:154
本文介绍了附加Visual Studio调试器会导致高CPU使用率和UI线程锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序做一些异步网络(并行协商超过100个套接字)。如果我启动附带VS调试器的应用程序,并启动网络代码,我的CPU使用率跳转到60%(在VS,VS调试器和vshost进程之间共享),并且UI变得非常无响应,常常冻结长达3秒。当我将调试器附加到已经运行的进程时也会发生这种情况。在正常情况下,它使用1-3%的CPU,UI平滑。



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屋!

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