简体   繁体   中英

Detect if Debugger is Attached *and* stepping through

I am aware of the Debugger class within the System.Diagnostics namespace which has the IsAttached property.

Is there a property, somewhere, that can augment this call and tell me if we're actually stepping through code, rather than simply just being attached? I understand this may be highly unlikely, but it would be useful to know.

EDIT

Perhaps a better question, rather than "stepping" is running some code:

  1. When the debugger "breaks" for the first time (enters debug mode, after being attached)
  2. When it runs again (but is still attached, but not "stepping through").

You can get the debugger state from the Debugger.CurrentMode property. But that's only going to tell you whether it is currently in the break state or if the program is running. There is no "step" mode, that's a fleeting moment which pretty much ensures that, if you could find about it, that acting on it would already be too late. Practically guaranteed to be a threading race.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM