private int DoRecovery(object state) { App.Source.TraceEvent(TraceEventType.Verbose, 0, "Begin recovery"); _tempPath = state as string; var canceled = ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress(); if (canceled) { TraceTextBlock.Text += string.Format("{0:T}: Recovery canceled, shutting down\n", DateTime.Now); // NOTE: Восстановление отменено, завершение работы App.Source.TraceEvent(TraceEventType.Verbose, 0, "End recovery with cancel"); ApplicationRestartRecoveryManager.ApplicationRecoveryFinished(false); return(0); } SaveFile(_tempPath); App.Source.TraceEvent(TraceEventType.Verbose, 0, "End recovery"); ApplicationRestartRecoveryManager.ApplicationRecoveryFinished(true); return(0); }
private int PerformRecovery(object parameter) { try { ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress(); if (System.IO.Directory.Exists("data") && System.IO.File.Exists("data/session.xml")) { recovery = true; new System.Threading.Thread(() => { MessageBox.Show("Hands Free Leveler might be crashed during a sesion\nRecovering from last rotation\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "Recovery Restart", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start(); } ApplicationRestartRecoveryManager.ApplicationRecoveryFinished(true); } catch { ApplicationRestartRecoveryManager.ApplicationRecoveryFinished(false); } return(0); }