- Task.Factory.StartNew(() =>
- Monitor.Start())
- .ContinueWith(t =>{
- if (t.IsFaulted)
- {
-
- var message= String.Format("An exception occured. Can't start monitoring\n{0}",t.Exception);
- _events.Publish(new Notification { Title = "Error",Message=message,Level= TraceLevel.Error });
- MessageBox.Show(message);
- }
- });
+ StartMonitor();
+ }
+
+ private void StartMonitor()
+ {
+ Task.Factory.StartNew(() =>
+ {
+ try
+ {
+ Monitor.Start();
+ }
+ catch(Exception exc)
+ {
+ var message = String.Format("An exception occured. Can't start monitoring\nWill retry in 10 seconds\n{0}",exc);
+ _events.Publish(new Notification{Title = "Error", Message = message, Level = TraceLevel.Error});
+ Task.Factory.StartNewDelayed(10000, StartMonitor);
+ }
+ });