Problem solved: Visual Studio stealing focus when breakpoint is hit
How many times have you been debugging and while you waited for a breakpoint to hit you switched to another application. Then, while you were typing, the breakpoint hits and focus is ripped from the application your were typing into and set to Visual Studio. In most cases the breakpoint is in code you have checked out so the worst thing that happens is that you overwrote some of your code, which can be easily remedied with the use of the Undo function.
I find this behavior to be very frustrating. Why did the Visual Studio team at Microsoft decide to do this? At a minimum they could have provided an option to turn it off.
I posted a request to a solution for this on my Twitter/Facebook status recently and a friend replied with a workaround – Tracepoints. Here’s how it works:
- Set your breakpoint at the desired location.
- Right-click on the red breakpoint dot icon and select “When Hit…”
- Select “Print a message”.
- Uncheck “Continue execution”.
You have effectively created a breakpoint that prints out the current function name and thread ID and name and then stops. Tracepoints don’t steal focus like normal breakpoints do.
This isn’t an ideal solution, but at least it’s a workaround that works.
Message to Microsoft: Please provide an option to turn off focus stealing in Visual Studio.



