When developing certain types of programs, different methods of debugging may be required in order to effectively and efficiently debug.
For example, programs with a timer iterative functions with a small interval, programs intercepting Window (WndProc) messages, or even programs with multiple hooks to the keyboard or mouse. All these type of programs have something in common…. it’s a major pain in the backside to ‘step-through’ (by default F10 in Visual Studio) without it jumping to areas non-related to the area of interest.
It’s not until recently that I discovered the DebuggerStepThrough attribute as a question answer on Stack Overflow.
Essentially, the DebuggerStepThrough attribute belongs to the Systems.Diagnostics namespace, and can be placed before almost any block of code to indicate to the debugger that it should pass/skip the block in question.
Decleration of DebuggerStepThrough in C#;
private void AnExampleSub()
// Annoying iterative code
Decleration of DebuggerStepThrough in VB.NET;
Private Sub AnExampleSub()
' Annoying iterative code
During debugging step through, the debugger will not visit anywhere within the subs in the examples above.