Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to stop Visual Studio auto focus when the debugger hit a breakpoint?

Would there be an option or registry setting to stop Visual Studio auto focusing itself when it hit a breakpoint?

The reason why I don't want Visual Studio auto focus itself is because I tend to do multi-tasking when I debug a software. When I start the debugger, it may takes awhile for the app to compile and hits the breakpoint. I usually takes this waiting time to reply emails.

As I type my email, the debugger would make visual Studio focus on the breaking line, and I would accidentally modified the source code as I am typing my email.

like image 530
dsum Avatar asked Jan 24 '11 23:01

dsum


People also ask

Why does Visual Studio not stop at breakpoint?

This problem occurs because ASP.NET debugging isn't enabled on the application.

What happens when a breakpoint is reached when the debugger is enabled?

If a breakpoint is reached, or a signal not related to stepping occurs before count steps, stepping stops right away. Continue to the next source line in the current (innermost) stack frame. This is similar to step , but function calls that appear within the line of code are executed without stopping.

How do you stop a breakpoint in Visual Studio?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

How do I stop a debugging session?

Terminate a debug sessionClick the Stop button on the toolbar of the Debug tool window. Alternatively, press Ctrl+F2 and select the process to terminate (if there are two or more of them).


2 Answers

I wasn't able to find any sort of config setting to turn it off but was able to find someone with a workaround; tracepoint.

1. Set your breakpoint at the desired location.
2. Right-click on the red breakpoint dot icon and select “When Hit…”
3. Select “Print a message”.
4. 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.

Credit goes to: http://dpotter.net/technical/2009/09/problem-solved-visual-studio-stealing-focus-when-breakpoint-is-hit/

like image 142
JoshKraker Avatar answered Nov 05 '22 15:11

JoshKraker


You can easily disable/enable this behaviour with the Option Settings in Visual Studio 2019:

Tools -> Options -> Debugging -> General -> Bring Visual Studio to the foreground when breaking in the debugger

enter image description here

I have no idea with what Visual Studio Version this feature has been added though.

like image 25
phifi Avatar answered Nov 05 '22 16:11

phifi