From 33d3e375b2668e8519d9928a2eeefc67d42b5652 Mon Sep 17 00:00:00 2001 From: dmex04 Date: Thu, 1 Oct 2009 19:16:04 +0000 Subject: [PATCH] fixed instances where two exceptions are generated, one by Win32 the other by PH when the runtime execution is allowed to continue when it is actually terminating git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2017 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker/Forms/ErrorDialog.cs | 12 +++++------- trunk/ProcessHacker/Program/Program.cs | 11 +++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/trunk/ProcessHacker/Forms/ErrorDialog.cs b/trunk/ProcessHacker/Forms/ErrorDialog.cs index d27f53244..0e406c10f 100644 --- a/trunk/ProcessHacker/Forms/ErrorDialog.cs +++ b/trunk/ProcessHacker/Forms/ErrorDialog.cs @@ -36,7 +36,7 @@ namespace ProcessHacker private Exception _exception; private string _trackerItem; - public ErrorDialog(Exception ex) + public ErrorDialog(Exception ex, bool terminating) { InitializeComponent(); @@ -44,12 +44,10 @@ namespace ProcessHacker textException.AppendText(_exception.ToString()); - try - { - textException.AppendText("\r\n\r\nDIAGNOSTIC INFORMATION\r\n" + Program.GetDiagnosticInformation()); - } - catch - { } + if (terminating) + buttonContinue.Enabled = false; + + textException.AppendText("\r\n\r\nDIAGNOSTIC INFORMATION\r\n" + Program.GetDiagnosticInformation()); } private void statusLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index d3bb9f307..f6729d83c 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -124,7 +124,7 @@ namespace ProcessHacker Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - + //Exclude PH from WER after setting up exception handling otherwise PH will be permanatly queued in Vista/Win7 Problem Reports and Solutions //the data and infomation will be sent to Microsoft and is completely useles to us without a DigitalCertificate //Native.Api.Win32.AddERExcludedApplication(AppDomain.CurrentDomain.FriendlyName); @@ -881,7 +881,6 @@ namespace ProcessHacker info.AppendLine(); info.AppendLine("PRIMARY SHARED THREAD PROVIDER"); - if (SharedThreadProvider != null) { info.AppendLine("Count: " + SharedThreadProvider.Count.ToString()); @@ -941,19 +940,19 @@ namespace ProcessHacker private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { - UnhandledException(e.ExceptionObject as Exception); + UnhandledException(e.ExceptionObject as Exception, e.IsTerminating); } private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { - UnhandledException(e.Exception); + UnhandledException(e.Exception, false); } - private static void UnhandledException(Exception ex) + private static void UnhandledException(Exception ex, bool terminating) { Logging.Log(Logging.Importance.Critical, ex.ToString()); - ErrorDialog ed = new ErrorDialog(ex); + ErrorDialog ed = new ErrorDialog(ex, terminating); ed.ShowDialog(); }