简体   繁体   中英

Is there a way to debug multithreaded applications in singletreaded mode in Visual Studio?

When I debug multithreaded .net applications I want the max degree of parallelism to be 1. I mean I want only one thread to run at a time.

In that way I wouldn't have to go through long tutorials about flagging threads, using parallel watch or learn how find out the ID of "my thread". All I am interested in is to debug multithreaded application in a singletreaded mode.

Is there any way of making Visual Studio work with one thread at a time? Or make my .net application single threaded with a global setting? Or a workaround, maybe set Windows 10 to run in singlethreaded mode? Be creative!

Is there a way to debug multithreaded applications in singletreaded mode in Visual Studio?

Just as Dialecticus suggested, you could try these:

Suggestion

1) Use Threads Window

  • first, set a breakpoint at the entry of the main function

  • start debugging and then enter Debug --> Windows --> Threads --> then right-click on the threads that you do not want to debug and then select Freeze . And note that you have to always click on switch to thread , every time something happens.

  • You can refer to this document about using Threads Window.

2) you can try to follow this document to set a new breakpoint about the specific single thread ID to debug it.

3) there is also a vs extension called Debug Single Thread . You can also use it.

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