How to debug a single thread in Visual Studio?

Here’s what I did:

  1. Set a conditional break point that I
    knew would only hit on the thread
    that I was looking for.

  2. Once the breakpoint hits and you are in the thread you want, in the Visual Studio Threads window (while debugging, Debug -> Windows -> Threads), Ctrl + A (to select all threads), and then Ctrl + click the thread you are currently on. You should have all threads except the one you want to debug selected.

  3. Right-click, and choose “Freeze”.

Now, Visual Studio will only step through the thawed thread. It seems to be much slower when doing this, presumably because it has to loop through all of the frozen threads, but it brought some sanity to my multi-threaded debugging.

Leave a Comment