From 75fe114a8c4f8ee6e4b738cb82110a771a7bbec0 Mon Sep 17 00:00:00 2001 From: jlewin Date: Fri, 22 Feb 2019 16:31:49 -0800 Subject: [PATCH] Ensure application exits on unhandled UI thread exceptions --- Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Program.cs b/Program.cs index 673366c60..e7434a2da 100644 --- a/Program.cs +++ b/Program.cs @@ -35,6 +35,7 @@ using System.ServiceModel; using System.ServiceModel.Description; using System.Threading; using MatterHackers.Agg.Platform; +using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.SettingsManagement; @@ -147,6 +148,13 @@ namespace MatterHackers.MatterControl { _raygunClient.Send(e.Exception); } + + if (System.Windows.Forms.Application.OpenForms.Count > 0 + && !System.Windows.Forms.Application.OpenForms[0].InvokeRequired) + { + System.Windows.Forms.Application.Exit(); + } + }; AppDomain.CurrentDomain.UnhandledException += (s, e) => @@ -155,6 +163,7 @@ namespace MatterHackers.MatterControl { _raygunClient.Send(e.ExceptionObject as Exception); } + System.Windows.Forms.Application.Exit(); }; }