public static void RegisterForRestart() { // Register for automatic restart if the application was terminated for any reason other than a system reboot or a system update. ApplicationRestartRecoveryManager.RegisterForApplicationRestart( new RestartSettings("-recovered", RestartRestrictions.NotOnReboot | RestartRestrictions.NotOnPatch)); }
public static void RegisterForRecovery() { // Since this registration is being done on application startup, we don't have a state currently. // In some cases it might make sense to pass this initial state. // Another approach: When doing "auto-save", register for recovery everytime, and pass // the current state I.E. data for recovery at that time. RecoveryData data = new RecoveryData(new RecoveryCallback(RecoveryProcedure), null); RecoverySettings settings = new RecoverySettings(data, 0); ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(settings); }