Search code examples
visual-studio-2010debuggingvisual-studio-debugging

Visual studio detect Ctrl+F5 and F5 mode?


Is there any way that I can understand that my code is running with Ctrl+F5 or F5?

I wrote a GUI for an application for some students but it doesn't work some time when run it with F5...I want too detect F5 and Ctrl+F5 mode to disable GUI when user run it with F5.


Solution

  • CTRL-F5 runs the application without the debugger attached. You can tell if it was started with plain F5 by checking the System.Diagnostics.Debugger.IsAttached.

    If the GUI sometimes breaks when run with a debugger attached, it is likely because you use multithreading incorrectly to access UI properties in a thread other than the main UI thread.