I know you can determine if a debugger is attached by using System.Diagnostics.Debugger.IsAttached, but is there a way of determining if a profiler is attached?
My profiler can’t trace tasks through the threadpool so I want to automaticly disable parallelism when profiling.
For the standard profiler interface, an environment variable needs to be set.
I guess you can just check this via the
Environmentclass.The variable is called
COR_ENABLE_PROFILINGand if enabled, will be set to1.