Visual Studio, debug one of multiple threads

前端 未结 7 837
孤街浪徒
孤街浪徒 2020-12-04 14:04

I have an application with 4 threads working the same code. However, when I step it jumps between the different threads. How can I lock it to one thread so the other threads

相关标签:
7条回答
  • 2020-12-04 14:39

    A much quicker workaround exists for simple cases - see comments in Steve's link.

    the debugger will only ever complete a step on the thread from which the step was originated. So if you hit a breakpoint, disable it, and then begin stepping you should not stop on a different thread. If you have other breakpoints in your application and another thread hits one, then you will be debugging in the mixed thread state as described

    So in my case once the various threads started hitting my breakpoint I just hit Continue a few times until I identified the call I was looking for - then removed the breakpoint and stepped through the rest of the code while remaining on the same thread without interference from the rest of them.

    This obviously becomes a problem if you have multiple breakpoints that you want to keep, etc. - but again for simple cases this is much easier to do.

    0 讨论(0)
提交回复
热议问题