/* * Process Hacker - * ProcessHacker Restart and Recovery Extensions * * Copyright (C) 2009 dmex * * This file is part of Process Hacker. * * Process Hacker is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Process Hacker is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Process Hacker. If not, see . * */ 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); } } }