C # VS2010 Determine in application whether to debug

Is it possible to determine in a C # application whether it is currently being debugged? The idea is to ignore, for example, timeouts, or provide additional information.

To make this clear, I'm not talking about the conditional flag of the DEBUG compiler. This allows me to decide how to compile the code. It does not provide information about whether it is running in the debugger or not.

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

+7
source share
2 answers

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

+9
source

System.Diagnostics.Debugger.IsAttached?

+7
source

All Articles