Welcome to MSDN Blogs Sign in | Join | Help

jfo's coding

adventures in windows forms and wpf
Tracepoints are AWESOME!
 So I was debugging a function this week that is called whenever my program is focused, which leads to a huge frustration when setting a breakpoint in it.  (You know the moment you F5 your debugger, then ALT+Tab back, the focus logic strikes again and you're back where you were a millisecond ago in the debugger.)

Typically to work around these situations, I've slapped in a few Debug.WriteLines, and started all over from scratch.  But this is annoying and time consuming, and I'm not always debugging code I can change.  Some folks solve this problem by using remote debugging, but if I'm too lazy to put in a Debug.WriteLine, I'm CERTAINLY too lazy to remote debug.

So I stumbled across a new feature (which folks have mentioned to me several times before but I had not yet seen the light). 

When you set a breakpoint in VS 2005, right click on it the next time, and select the "When hit..." option.  This will change your breakpoint into a tracepoint!  A tracepoint does not stop the debugger, it simply spews output into the output window when it is hit. 

So, the next time you're debugging something in VS, take a minute, right click and enjoy the wonder that is "when hit".

Instructions for creating a tracepoint.

 

Posted: Thursday, March 16, 2006 10:45 PM by jfoscoding

Comments

random ramblings.... said:

-- Microsoft Products Developed in .NET A brief summary of the approximate number of lines of .net code in various MS products, which is a question I've seen asked by a lot of people in a lot of places. Not...
# March 17, 2006 4:31 AM

Roger said:

What about multiple monitors?
Very useful when debugging GUI-code.
# March 17, 2006 7:21 AM

Matty4242 said:

Oh man - thanks for the tip - this is going to minimize my insanity!
# March 17, 2006 9:32 AM

Josh Einstein said:

# March 17, 2006 10:44 PM

G said:

# March 19, 2006 7:04 AM

ericgu said:

Roger,

Multi-mon helps with some UI code, but there's still a big class of issues where having the focus move to the debugger mucks things up.

I disagree with Chris about remote debugging. I'm pretty lazy as well, but I do remote debugging all the time. All you need is a way to interrupt your program when it starts - a parameter that calls MessageBox works well - and then you can easily attach and debug.

I do spend a lot of time switching on my switchbox.
# March 19, 2006 10:47 AM

Darren Jefford said:

I read this, and I'm hooked!  Visual Studio drives me mad when it snatches focus back when you hit...
# March 20, 2006 8:15 AM

TrackBack said:

# March 21, 2006 12:26 AM

CoqBlog said:

Pour ceux qui ne seraient pas (encore) abonnés aux Z'actus d'ASP-MAGAZINE, voici une information concernant...
# May 5, 2006 7:48 PM

jfo's coding said:





For the most part, activation and focus work pretty darn well in windows, until you want to tweak...
# August 2, 2006 3:31 AM

CoqBlog said:

Pour ceux qui ne seraient pas (encore) abonnés aux Z'actus d' ASP-MAGAZINE , voici une information concernant

# March 16, 2007 7:52 PM
New Comments to this post are disabled
Page view tracker