Question

I'm using VS2010 Beta 2 to debug some multi-threaded code. Love parallel stacks, etc.

I have a question, though: I have a breakpoint set in a method that may be called by multiple threads. Once I hit the breakpoint, I really want to keep the focus on the thread that triggered the that breakpoint. However, when I hit "step", VS often switches to another thread (say I'm stopped on thread 1, but in the meanwhile, thread 2 hits my breakpoint).

I know that I can manually freeze threads in the thread window. Is there a way to do it automatically -- basically, once I hit a breakpoint, freeze all threads except the current one until I hit F-5?

Was it helpful?

Solution

Not that I'm aware of, however you could disable your breakpoint while you are stepping through.

When I'm worried about confusing many threads I tend to just keep the threads window open and keep a note of the thread id's.

OTHER TIPS

I have just released a Visual Studio 2010 extension that does exactly what you are looking for. And it's free :).

Presentation

This Visual Studio 2010 extension adds two shortcuts and toolbar buttons to allow developers to easily focus on single threads while debugging multi-threaded applications.

It dramatically reduces the need to manually go into the Threads window to freeze/thaw all threads but the one that needs to be followed, and therefore helps improve productivity.

Features

Restrict further execution to the current thread only. Will freeze all other threads. Shortcut: CTRL+T+T or Snowflake button. Switch to the next single thread (based on ID). Will change current thread and freeze all other threads. Shortcut: CTRL+T+J or Next button.

Check it out here on the Gallery, on the official page or the Codeplex repository.

If you load the Threads window from Debug->Windows->Threads.. Once you hit a break point, you can select all the threads and click "Freeze Threads" then you can resume the active thread, selecting it and choosing "Thaw threads".

This will allow only the current thread to execute in the debugger.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top