Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

if(System.Diagnostics.Debugger.IsAttached)
{
    // ...
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...