Debugging multithreaded applications is always hard, so any help we can get from the debugger is appreciated.
Here’s one tip that can help using Visual Studio 2010 when many threads are running at the same time, some of which run similar code.It’s tedious to lookup each thread’s call stack to see where its next instruction pointer is located. Here’s the Threads window in action:
To find the actual source line each thread is at the breakpoint moment, we’ll need to switch to that thread by double clicking it in the Threads window and then we’ll see something like this in the editor:
We can keep double clicking threads and get to each one’s source.
The Debug toolbar has a nice alternative, called “Show Threads in Source”:
Clicking the marked button causes Visual Studio to show locations of other threads with a special icon:
This means there is at least one thread is at the location marked with the “wavy” icon. Hovering that icon displays a tooltip for those threads that are, in fact, at that source line:
With this, you can get a quick sense of where threads are running at the moment.