private void ReturnToAlarms(object obj) { if (Application.Current.Dispatcher != null) { Application.Current.Dispatcher.Invoke(new Action(() => { _tokenSource.Cancel(); _workingThread.Abort(); NavigationManager.Instance.Navigate(ViewType.Alarms); AlarmsViewModel.StartWorkingThread(); })); } }
private static void StartWorkingThreadProcess() { DateTime stop = DateTime.Now.AddMinutes(2); while (!_token.IsCancellationRequested && stop > DateTime.Now) { Thread.Sleep(1000); } if (Application.Current.Dispatcher != null) { Application.Current.Dispatcher.Invoke(new Action(() => { _tokenSource.Cancel(); _workingThread.Abort(); NavigationManager.Instance.Navigate(ViewType.Alarms); AlarmsViewModel.StartWorkingThread(); })); } }