private static UInt32 InternalRecoveryHandler(IntPtr parameter)
        {
            bool cancelled = false;

            ApplicationRecoveryInProgress(out cancelled);

            GCHandle     handle = GCHandle.FromIntPtr(parameter);
            RecoveryData data   = handle.Target as RecoveryData;

            data.Invoke();
            handle.Free();

            return(0);
        }
 /// <summary>
 /// Initializes a new instance of the <b>RecoverySettings</b> class.
 /// </summary>
 /// <param name="data">A recovery data object that contains the callback method (invoked by the system
 /// before Windows Error Reporting terminates the application) and an optional state object.</param>
 /// <param name="interval">The time interval within which the 
 /// callback method must invoke <see cref="ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress"/> to 
 /// prevent WER from terminating the application.</param>
 /// <seealso cref="ApplicationRestartRecoveryManager"/>
 public RecoverySettings(RecoveryData data, uint interval)
 {
     this.recoveryData = data;
     this.pingInterval = interval;
 }
        private void RegisterForRecovery()
        {
            // Don't pass any state. We'll use our static variable "CurrentFile" to determine
            // the current state of the application.
            // 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 at that time. 
            RecoveryData data = new RecoveryData(new RecoveryCallback(RecoveryProcedure), null);
            RecoverySettings settings = new RecoverySettings(data, 0);

            ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(settings);

            Debug.WriteLine("ARR: Registered for recovery");
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <b>RecoverySettings</b> class.
 /// </summary>
 /// <param name="data">A recovery data object that contains the callback method (invoked by the system
 /// before Windows Error Reporting terminates the application) and an optional state object.</param>
 /// <param name="interval">The time interval within which the
 /// callback method must invoke <see cref="ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress"/> to
 /// prevent WER from terminating the application.</param>
 /// <seealso cref="ApplicationRestartRecoveryManager"/>
 public RecoverySettings(RecoveryData data, uint interval)
 {
     this.recoveryData = data;
     this.pingInterval = interval;
 }
Example #5
0
 /// <summary>Initializes a new instance of the <b>RecoverySettings</b> class.</summary>
 /// <param name="data">
 /// A recovery data object that contains the callback method (invoked by the system before Windows Error Reporting terminates the
 /// application) and an optional state object.
 /// </param>
 /// <param name="interval">
 /// The time interval within which the callback method must invoke
 /// <see cref="ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress"/> to prevent WER from terminating the application.
 /// </param>
 /// <seealso cref="ApplicationRestartRecoveryManager"/>
 public RecoverySettings(RecoveryData data, uint interval)
 {
     recoveryData = data;
     pingInterval = interval;
 }