简体   繁体   中英

Attaching Visual Studio debugger causes high CPU usage and UI thread locks

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM