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 are ignored for debugging?
Yes.
In the Threads window (Debug -> Windows -> Threads) right-click the thread you want and select "switch to thread".
You can also choose "freeze" on the threads you don't want to debug
in order to keep them from running. Don't forget to "thaw" them if you
expect them to do work, however.
Freezing and thawing threads is the usual workaround, as previous
answers have stated, but it's tedious, and it can cause hangs when your
thread waits on another thread that's frozen. These can be tough to
recover from without losing your place in your thread of interest.
Another useful workflow is to apply a thread filter on your breakpoints, also stated in some of the answers:
Create a breakpoint, right click on the breakpoint, click Filter, and
enter ThreadId = 7740 (your thread id from the threads window).
This can be very tedious.
No comments:
Post a Comment