diff --git a/Window/Properties/Resources.Designer.cs b/Window/Properties/Resources.Designer.cs index 46192f1..bf1dbb4 100644 --- a/Window/Properties/Resources.Designer.cs +++ b/Window/Properties/Resources.Designer.cs @@ -242,6 +242,24 @@ namespace SystemTemperatureStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Service not installed - please restart application. + /// + public static string ServiceNotInstalled { + get { + return ResourceManager.GetString("ServiceNotInstalled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waiting for service to start.... + /// + public static string ServiceNotStarted { + get { + return ResourceManager.GetString("ServiceNotStarted", resourceCulture); + } + } + /// /// Looks up a localized string similar to _Start when Windows starts. /// diff --git a/Window/Properties/Resources.resx b/Window/Properties/Resources.resx index f030313..a74c0df 100644 --- a/Window/Properties/Resources.resx +++ b/Window/Properties/Resources.resx @@ -190,4 +190,10 @@ Options + + Service not installed - please restart application + + + Waiting for service to start... + \ No newline at end of file diff --git a/Window/WindowSource.cs b/Window/WindowSource.cs index e19bb1c..d6d6515 100644 --- a/Window/WindowSource.cs +++ b/Window/WindowSource.cs @@ -1,4 +1,5 @@ -using FloatingStatusWindowLibrary; +using Common.Wpf.Windows; +using FloatingStatusWindowLibrary; using Microsoft.Win32.TaskScheduler; using System; using System.Collections.Generic; @@ -12,8 +13,6 @@ using System.Windows.Threading; using SystemTemperatureStatusWindow.Options; using SystemTemperatureStatusWindow.Properties; using SystemTemperatureStatusWindow.SystemTemperatureService; -using Common.Wpf.Windows; -using Task = Microsoft.Win32.TaskScheduler.Task; namespace SystemTemperatureStatusWindow { @@ -63,7 +62,6 @@ namespace SystemTemperatureStatusWindow _refreshTimer = new Timer(Settings.Default.UpdateInterval) { AutoReset = false }; _refreshTimer.Elapsed += HandleTimerElapsed; - System.Threading.Tasks.Task.Factory.StartNew(UpdateApp).ContinueWith(task => StartUpdate(task.Result.Result)); } @@ -97,6 +95,23 @@ namespace SystemTemperatureStatusWindow { try { + using (var taskService = new TaskService()) + { + var existingTask = taskService.FindTask(ScheduledTaskName); + + if (existingTask == null) + { + UpdateText(Resources.ServiceNotInstalled); + return; + } + + if (existingTask.State != TaskState.Running) + { + UpdateText(Resources.ServiceNotStarted); + return; + } + } + using (var client = new SystemTemperatureServiceClient()) { var builder = new StringBuilder();