How Do I: Create a Breakpoint Using Conditions? [C# Express]
breakpoints, c#, visual-studio, visual-studio-2008, visual-studio-2010
Solution
Similar to @Relster I have a code snippet with the following
#if DEBUG
if( node.Name == "Book" )
System.Diagnostics.Debugger.Break();
#endif
Where `node.Name == "Book"` changes based on the condition I want to test for. the `#if DEBUG` wrapper makes sure the checks never make it to release code.
This is also a lot faster than using the conditional breakpoints in Visual Studio. When you use the built in conditional bp visual studio has to break into the app, pause all the threads, evaluate the expression and determine if it is true each time it hits the breakpoint. In a tight loop this can be the difference between near full execution performance and running at a crawl.
Problem
I've been seeing this in my Visual C# 2008 RSS Feed forever now: http://lincolnfair.net/oldLincolnFair/mad.jpg I'm pretty sure this is a VS 2010 only feature, but I was wondering if there is anyway to replicate this in VS 2008?