From 6f1f60dfbf61aa34d97f8fcfdae67af759dd507b Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Wed, 1 Feb 2017 11:50:47 -0500 Subject: [PATCH] Make sure timer restarts in case of exception --- WindowSource.cs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/WindowSource.cs b/WindowSource.cs index 77c98e4..c920365 100644 --- a/WindowSource.cs +++ b/WindowSource.cs @@ -72,17 +72,31 @@ namespace JenkinsStatusWindow private void UpdateText() { - var textResult = GetText(); - - // Update the window on the main thread - _dispatcher.Invoke(() => + try { - _floatingStatusWindow.SetText(textResult.WindowText.ToString()); + var textResult = GetText(); - _floatingStatusWindow.IconToolTipText = textResult.TooltipText.ToString(); - }); + // Update the window on the main thread + _dispatcher.Invoke(() => + { + _floatingStatusWindow.SetText(textResult.WindowText.ToString()); - _refreshTimer.Start(); + _floatingStatusWindow.IconToolTipText = textResult.TooltipText.ToString(); + }); + } + catch (Exception exception) + { + _dispatcher.Invoke(() => + { + _floatingStatusWindow.SetText(exception.Message); + + _floatingStatusWindow.IconToolTipText = exception.Message; + }); + } + finally + { + _refreshTimer.Start(); + } } private TextResult GetText()