mirror of https://github.com/ShareX/ShareX.git
Check Debugger.IsAttached
This commit is contained in:
parent
6d353451be
commit
742f1af7d9
|
@ -267,19 +267,9 @@ namespace ShareX
|
|||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
// Allow Visual Studio to break on exceptions in Debug builds
|
||||
#if !DEBUG
|
||||
// Add the event handler for handling UI thread exceptions to the event
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
HandleExceptions();
|
||||
|
||||
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
|
||||
// Add the event handler for handling non-UI thread exceptions to the event
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
#endif
|
||||
|
||||
StartTimer = Stopwatch.StartNew(); // For be able to show startup time
|
||||
StartTimer = Stopwatch.StartNew();
|
||||
|
||||
CLI = new ShareXCLIManager(args);
|
||||
CLI.ParseCommands();
|
||||
|
@ -625,6 +615,25 @@ namespace ShareX
|
|||
return false;
|
||||
}
|
||||
|
||||
private static void HandleExceptions()
|
||||
{
|
||||
#if DEBUG
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add the event handler for handling UI thread exceptions to the event
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
|
||||
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
|
||||
// Add the event handler for handling non-UI thread exceptions to the event
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
}
|
||||
|
||||
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
OnError(e.Exception);
|
||||
|
|
Loading…
Reference in New Issue