private static void HandleException(Exception exception) { //System.ComponentModel.CancelEventArgs e= new System.ComponentModel.CancelEventArgs(); //e.Cancel = true; //Application.Exit(e); //Application.Exit(); //Environment.Exit(0); if (SystemInformation.UserInteractive) { ShowMessageBox("UnhandledException", exception); //return; using (ThreadExceptionDialog dialog = new ThreadExceptionDialog(exception)) { if (dialog.ShowDialog() == DialogResult.Cancel) return; } Application.Exit(); Environment.Exit(0); } }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { Logger.Log(e.Exception.ToString()); { if (!SystemInformation.UserInteractive) return; DialogResult dialogResult; using (var threadExceptionDialog = new ThreadExceptionDialog(e.Exception)) { dialogResult = threadExceptionDialog.ShowDialog(); } switch (dialogResult) { case DialogResult.Abort: Application.Exit(); Environment.Exit(0); break; case DialogResult.Yes: var warningException = e.Exception as WarningException; if (warningException == null) break; Help.ShowHelp(null, warningException.HelpUrl, warningException.HelpTopic); break; } } }
/// <summary> /// 显示异常详细信息 /// </summary> /// <param name="ex"></param> /// <param name="title"></param> /// <returns></returns> public static DialogResult ShowException(Exception ex, string title = "错误") { var frm = new ThreadExceptionDialog(ex); frm.Text = title; return(frm.ShowDialog()); }
static void OnThreadException(object sender, ThreadExceptionEventArgs args) { if (SystemInformation.UserInteractive) { using (ThreadExceptionDialog dialog = new ThreadExceptionDialog(args.Exception)) { if (dialog.ShowDialog() == DialogResult.Cancel) return; } Application.Exit(); Environment.Exit(0); } }
private static void HandleThreadException(object sender, string caption, Exception ex) { try { ThreadExceptionDialog dlg = new ThreadExceptionDialog (ex); dlg.Text = caption; if (dlg.ShowDialog () == DialogResult.Abort) { Application.Exit (); } } catch {} }
private static void Main() { try { Application.EnableVisualStyles(); Application.DoEvents(); Application.Run(new PlayForm()); } catch (Exception err) { using (ThreadExceptionDialog errDlg = new ThreadExceptionDialog(err)) { errDlg.ShowDialog(); } } }
public static void OnThreadException(Exception t) { if (MWFThread.Current.HandlingException) { /* we're already handling an exception and we got * another one? print it out and exit, this means * we've got a runtime/SWF bug. */ Console.WriteLine(t); // Don't use Application.Exit here, since it may cause a stack overflow // in certain cases. It's however hard to reproduce since it seems to // be depending on when the GC kicks in. Environment.Exit(1); } try { MWFThread.Current.HandlingException = true; if (Application.ThreadException != null) { Application.ThreadException(null, new ThreadExceptionEventArgs(t)); return; } if (SystemInformation.UserInteractive) { Form form = new ThreadExceptionDialog(t); form.ShowDialog(); } else { Console.WriteLine(t.ToString()); Application.Exit(); } } finally { MWFThread.Current.HandlingException = false; } }
private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e) { try { using(new HourGlass(this)) { CheckForUpdates updateChecker = new CheckForUpdates(); updateChecker.PadUrl = Program.PadUrl; updateChecker.PromptAlways = true; updateChecker.SendReport(null); } } catch (Exception ex) { ThreadExceptionDialog dlg = new ThreadExceptionDialog(ex); dlg.Text = "Error checking for new updates"; dlg.ShowDialog(this); } }
public static void OnThreadException (Exception t) { if (MWFThread.Current.HandlingException) { /* we're already handling an exception and we got another one? print it out and exit, this means we've got a runtime/SWF bug. */ Console.WriteLine (t); // Don't use Application.Exit here, since it may cause a stack overflow // in certain cases. It's however hard to reproduce since it seems to // be depending on when the GC kicks in. Environment.Exit(1); } try { MWFThread.Current.HandlingException = true; if (Application.ThreadException != null) { Application.ThreadException(null, new ThreadExceptionEventArgs(t)); return; } if (SystemInformation.UserInteractive) { Form form = new ThreadExceptionDialog (t); form.ShowDialog (); } else { Console.WriteLine (t.ToString ()); Application.Exit (); } } finally { MWFThread.Current.HandlingException = false; } }
private void execButton_Click(object sender, System.EventArgs e) { AppForm ().ClearExecutionModelTabs (); try { ICommand command = new ExecuteHsmCommand (_Model, this, _LastFileName); command.Execute (); } catch (Exception ex) { Exception ex2 = new Exception ("Model represented by " + _LastFileName + " could not be loaded for execution", ex); ThreadExceptionDialog dialog = new ThreadExceptionDialog (ex2); dialog.ShowDialog (); } }
private void timer1_Tick(object sender, EventArgs e) { Queue<ProfilerEvent> saved; Exception exc; lock (this) { saved = m_events; m_events = new Queue<ProfilerEvent>(10); exc = m_profilerexception; m_profilerexception = null; } if (null != exc) { using (ThreadExceptionDialog dlg = new ThreadExceptionDialog(exc)) { dlg.ShowDialog(); } } lock (m_Cached) { while (0 != saved.Count) { NewEventArrived(saved.Dequeue(), 0 == saved.Count); } if (m_Cached.Count > m_currentsettings.Filters.MaximumEventCount) { while (m_Cached.Count > m_currentsettings.Filters.MaximumEventCount) { m_Cached.RemoveAt(0); } lvEvents.VirtualListSize = m_Cached.Count; lvEvents.Invalidate(); } if ((null == m_prev) || (DateTime.Now.Subtract(m_prev.m_date).TotalSeconds >= 1)) { PerfInfo curr = new PerfInfo { m_count = m_EventCount }; if (m_perf.Count >= 60) { m_first = m_perf.Dequeue(); } if (null == m_first) m_first = curr; if (null == m_prev) m_prev = curr; DateTime now = DateTime.Now; double d1 = now.Subtract(m_prev.m_date).TotalSeconds; double d2 = now.Subtract(m_first.m_date).TotalSeconds; slEPS.Text = String.Format("{0} / {1} EPS(last/avg for {2} second(s))", (Math.Abs(d1 - 0) > 0.001 ? ((curr.m_count - m_prev.m_count) / d1).ToString("#,0.00") : ""), (Math.Abs(d2 - 0) > 0.001 ? ((curr.m_count - m_first.m_count) / d2).ToString("#,0.00") : ""), d2.ToString("0")); m_perf.Enqueue(curr); m_prev = curr; } } }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { _progress.Close(); _progress = null; if (e.Error != null) { ThreadExceptionDialog ted = new ThreadExceptionDialog(e.Error); ted.ShowDialog(); } else { SetStatus(_eltl.HighestLoggedLevel); _ac = (AssemblyComparison)e.Result; if (_ac != null) { ApplyFilter(); } } }
/// <include file='doc\Application.uex' path='docs/doc[@for="Application.ThreadContext.OnThreadException"]/*' /> /// <devdoc> /// Called when an untrapped exception occurs in a thread. This allows the /// programmer to trap these, and, if left untrapped, throws a standard error /// dialog. /// </devdoc> /// <internalonly/> internal void OnThreadException(Exception t) { if (GetState(STATE_INTHREADEXCEPTION)) return; SetState(STATE_INTHREADEXCEPTION, true); try { if (threadExceptionHandler != null) { threadExceptionHandler(Thread.CurrentThread, new ThreadExceptionEventArgs(t)); } else { if (SystemInformation.UserInteractive) { ThreadExceptionDialog td = new ThreadExceptionDialog(t); DialogResult result = DialogResult.OK; // SECREVIEW : This Assert is ok, this dialog shows up when the application is about to die. // ShowDialog will generate a call to ContainerControl.SetActiveControl which demands // ModifyFocus permission, need to assert it here. // IntSecurity.ModifyFocus.Assert(); try { result = td.ShowDialog(); } finally { CodeAccessPermission.RevertAssert(); td.Dispose(); } switch (result) { case DialogResult.Abort: // SECREVIEW : The user clicked "Quit" in response to a exception dialog. // : We only show the quit option when we own the message pump, // : so this won't ever tear down IE or any other ActiveX host. // : // : This has a potential problem where a component could // : cause a failure, then try a "trick" the user into hitting // : quit. However, no component or application outside of // : the windows forms assembly can modify the dialog, so this is // : a really minor concern. // Application.ExitInternal(); // SECREVIEW : We can't revert this assert... after Exit(0) is called, no // : more code is executed... // new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); Environment.Exit(0); break; case DialogResult.Yes: WarningException w = t as WarningException; if (w != null) { Help.ShowHelp(null, w.HelpUrl, w.HelpTopic); } break; } } else { // Ignore unhandled thread exceptions. The user can // override if they really care. // } } } finally { SetState(STATE_INTHREADEXCEPTION, false); } }
internal void OnThreadException(Exception t) { if (!this.GetState(4)) { this.SetState(4, true); try { WarningException exception; if (this.threadExceptionHandler != null) { this.threadExceptionHandler(Thread.CurrentThread, new ThreadExceptionEventArgs(t)); } else if (SystemInformation.UserInteractive) { ThreadExceptionDialog dialog = new ThreadExceptionDialog(t); DialogResult oK = DialogResult.OK; System.Windows.Forms.IntSecurity.ModifyFocus.Assert(); try { oK = dialog.ShowDialog(); } finally { CodeAccessPermission.RevertAssert(); dialog.Dispose(); } switch (oK) { case DialogResult.Abort: Application.ExitInternal(); new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); Environment.Exit(0); break; case DialogResult.Yes: goto Label_0086; } } return; Label_0086: exception = t as WarningException; if (exception != null) { Help.ShowHelp(null, exception.HelpUrl, exception.HelpTopic); } } finally { this.SetState(4, false); } } }