From 0df1edbc1d8aa3b1e09d40163f82dc6d3e3cb2ee Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Mon, 10 Jul 2017 14:05:45 -0700 Subject: [PATCH] Enhance Paranoia. Closes #1071. Closes #1074 --- src/Update/AnimatedGifWindowWinForms.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Update/AnimatedGifWindowWinForms.cs b/src/Update/AnimatedGifWindowWinForms.cs index 1cfc738c5..6626d6527 100644 --- a/src/Update/AnimatedGifWindowWinForms.cs +++ b/src/Update/AnimatedGifWindowWinForms.cs @@ -66,7 +66,13 @@ public static void ShowWindow(TimeSpan initialDelay, CancellationToken token, Pr } var wnd = new AnimatedGifWindow(); - wnd.Show(); + if (token.IsCancellationRequested) return; + + try { + wnd.Show(); + } catch (Exception) { + return; + } token.Register(() => wnd.Invoke(new Action(() => wnd.Close()))); @@ -93,7 +99,17 @@ public static void ShowWindow(TimeSpan initialDelay, CancellationToken token, Pr wnd.Invoke(new Action(() => wnd.TopMost = false)); }); - Application.Run(wnd); + if (token.IsCancellationRequested) return; + +#if !DEBUG + try { +#endif + Application.Run(wnd); +#if !DEBUG + } catch (Exception) { + return; + } +#endif }); thread.SetApartmentState(ApartmentState.STA);