private void RestartSystem() { this.IsEnabled = false; lbItems.ItemsSource = null; BackgroundWorker w = new BackgroundWorker(); w.DoWork += (s, e) => { try { _sys.SwitchServiceBus(_sys.Config.ServiceBus, _sys.Config.ServiceBusVersion, _sys.Config.ServiceBusQueueType); _mgr = _sys.Manager; } catch (RestartRequiredException) { e.Cancel = true; } }; w.RunWorkerCompleted += (s, e) => { if (!e.Cancelled) { this.IsEnabled = true; RestoreMonitorQueueState(); btnSendCommand.IsEnabled = _sys.CanSendCommand; btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions; lbItems.ItemsSource = _sys.Items; if (!lbItems.IsEnabled) { lbItems.IsEnabled = true; } SetupContextMenu(); UpdateTitle(); _sys.StartMonitoring(); } else // Restart needed { System.Diagnostics.Process.Start(Application.ResourceAssembly.Location, "-f"); Application.Current.Shutdown(); } }; w.RunWorkerAsync(); }