Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# VS2010 Determine in application whether being debugged

Is there a chance to determine in an C# application whether it is currently being debugged? The idea is to ignore e.g timeouts, or to provide additional information.

Just to make this clear, I am not talking about the conditional compiler flag DEBUG. This allows me to decide how the code shall be compiled. It gives no information about whether it is run in a debugger or not.

I need to decide at runtime, not at compile time.

like image 397
Horst Walter Avatar asked Jan 07 '11 17:01

Horst Walter


1 Answers

You can use the Debugger.IsAttached flag to determine this.

like image 133
Matthew Abbott Avatar answered Oct 13 '22 02:10

Matthew Abbott