From c15f589a8f6b90b4051bb74e89b16d18e0f3b4ae Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 22 Oct 2017 16:34:19 +0300 Subject: [PATCH] do not crash when other threads failed --- QuickLook/App.config | 1 + QuickLook/App.xaml.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/QuickLook/App.config b/QuickLook/App.config index 4b4680b3..d7d44a48 100644 --- a/QuickLook/App.config +++ b/QuickLook/App.config @@ -14,6 +14,7 @@ + diff --git a/QuickLook/App.xaml.cs b/QuickLook/App.xaml.cs index 66777328..15f3f65d 100644 --- a/QuickLook/App.xaml.cs +++ b/QuickLook/App.xaml.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using System; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -44,9 +45,13 @@ namespace QuickLook { AppDomain.CurrentDomain.UnhandledException += (sender, args) => { - MessageBox.Show(((Exception) args.ExceptionObject).ToString()); + //MessageBox.Show(((Exception) args.ExceptionObject).ToString()); - Shutdown(); + const string source = "QuickLook Application Error"; + if (!EventLog.SourceExists(source)) + EventLog.CreateEventSource(source, "Application"); + EventLog.WriteEntry(source, ((Exception) args.ExceptionObject).ToString(), + EventLogEntryType.Error); }; base.OnStartup(e);