private void OnServiceMonitorStateChanged(object sender, ServiceMonitorStateEventArgs e) { switch (e.State) { case ServiceMonitorState.Online: TaskbarItemInfo.Overlay = null; break; case ServiceMonitorState.Offline: TaskbarItemInfo.Overlay = (ImageSource)Resources["OfflineImage"]; break; case ServiceMonitorState.NotResponding: TaskbarItemInfo.Overlay = (ImageSource)Resources["WarningImage"]; break; default: throw new ArgumentOutOfRangeException(); } }
public void InvokeServiceMonitorStateChanged(ServiceMonitorStateEventArgs e) { var handler = ServiceMonitorStateChanged; if (handler == null) return; if (Application.Current.Dispatcher.Thread.Equals(Thread.CurrentThread)) { handler(this, e); } else { Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, handler, this, e); } }