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”.