I have a program that Process.Start()
another program, and it shuts it down after N seconds.
Sometimes I choose to attach a debugger to the started program. In those cases, I don't want the process shut down after N seconds.
I'd like the host program to detect if a debugger is attached or not, so it can choose to not shut it down.
Clarification: I'm not looking to detect if a debugger is attached to my process, I'm looking to detect if a debugger is attached to the process I spawned.
if(System.Diagnostics.Debugger.IsAttached) { // ... }
You will need to P/Invoke down to CheckRemoteDebuggerPresent. This requires a handle to the target process, which you can get from Process.Handle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With