VS2008 Suspend all threads when a breakpoint is reached

Something is missing for me. (I'm used to using eclipse)

Visual Studio 2008 seems to pause all threads when I hit the breakpoint - is this normal? If so, is there an option that only pauses the thread hit by the breakpoint?

+4
source share
2 answers

Yes, this is quite normal for the debugger. Think about what will happen if it does not. Any value displayed by the debugger should be considered obsolete from the moment it is displayed, because any of the other working threads can change the value from under it.

I do not believe that there is a way to hack Visual Studio without pausing all threads.

+2
source

As Jared said, this is normal behavior in VS. However, there are some things you can do to customize behavior, like creating breakpoint conditions. I found an article that mentions setting a breakpoint condition to search for a specific thread:

Tip. A break is only when a specific thread calls a method:. To set a breakpoint on a thread, you need to uniquely identify the specific thread that you gave the name with its name. You can set a conditional breakpoint for a thread by creating a conditional expression such as "ThreadToStopOn" == Thread.CurrentThread.Name.

You can manually change the name of the stream in the "Observation" window by looking at the "myThread" variable and entering a value for it in the value window. If you do not have a current thread variable that you can work with, you can use Thread.CurrentThread.Name to set the current thread name. There is also a private integer variable in the Thread class, DONT_USE_InternalThread, which is unique to each thread. You can use the Themes window to go to the thread you want to stop, and in the Clock window, enter Thread.CurrentThread.DONT_USE_InternalThread to see its value so that you can create the correct conditional breakpoint expression.

Here are a few more articles that cover breakpont conditions:

http://www.professionalvisualstudio.com/blog/2009/04/30/debugging-threads-in-visual-studio-with-breakpoint-conditions-and-actions/

http://www.blackwasp.co.uk/VSBreakpoints.aspx

+1
source

Source: https://habr.com/ru/post/1310126/


All Articles