/*
* 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;
namespace ProcessHackerRestartRecovery
{
///
/// Defines methods and properties for recovery settings, and specifies options for an application that attempts
/// to perform final actions after a fatal event, such as an unhandled exception.
///
/// This class is used to register for application recovery.
/// See the ApplicationRestartRecoveryManager class.
///
public class RecoverySettings
{
private RecoveryData recoveryData;
private uint pingInterval;
///
/// Initializes a new instance of the RecoverySettings class.
///
/// 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.
/// The time interval within which the
/// callback method must invoke ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress to
/// prevent WER from terminating the application.
public RecoverySettings(RecoveryData data, uint interval)
{
this.recoveryData = data;
this.pingInterval = interval;
}
///
/// Gets the recovery data object that contains the callback method and an optional
/// parameter (usually the state of the application) to be passed to the callback method.
///
/// A RecoveryData object.
public RecoveryData RecoveryData
{
get { return recoveryData; }
}
///
/// Gets the time interval for notifying Windows Error Reporting.
/// The RecoveryCallback method must invoke ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress
/// within this interval to prevent WER from terminating the application.
///
///
/// The recovery ping interval is specified in milliseconds.
/// By default, the interval is 5 seconds.
/// If you specify zero, the default interval is used.
///
public uint PingInterval
{
get { return pingInterval; }
}
///
/// Returns a string representation of the current state of this object.
///
/// A String object.
public override string ToString()
{
return String.Format("delegate: {0}, state: {1}, ping: {2}",
this.recoveryData.Callback.Method.ToString(),
this.recoveryData.State.ToString(),
this.PingInterval);
}
}
}