using System; using System.Runtime.InteropServices; namespace ProcessHackerRestartRecovery { /// /// The Delegate that represents the callback method invoked by the system when an application has registered for application recovery. /// /// An application-defined state object that is passed to the callback method. /// The callback method will be invoked prior to the application being terminated by Windows Error Reporting (WER). /// To keep WER from terminating the application before the callback method completes, the callback method must /// periodically call the ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress method. public delegate int RecoveryCallback(object state); /// /// Defines a class that contains a callback delegate and properties of the application as defined by the user. /// public class RecoveryData { /// /// Initializes a recovery data wrapper with a callback method and the current state of the application. /// /// The callback delegate. /// The current state of the application. public RecoveryData(RecoveryCallback callback, object state) { Callback = callback; State = state; } /// /// Gets or sets a value that determines the recovery callback function. /// public RecoveryCallback Callback { get; set; } /// /// Gets or sets a value that determines the application state. /// public object State { get; set; } /// /// Invokes the recovery callback function. /// public void Invoke() { if(Callback != null) Callback(State); } } }