Universal Windows Service Class Library

FailureAction Class

Class to represent a failure action which consists of a recovery action type and an action delay.

For a list of all members of this type, see FailureAction Members.


public class FailureAction

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


This class represent one failure action which will be started after service fails. For possible recover actions see RecoverAction.


ExtendedServiceInstaller service = new ExtendedServiceInstaller();

service.ServiceName = "myTestService";

// The fail count reset time resets the failure count after n seconds of no failures
// on the service. This value is set in seconds, though note that the SCM GUI only
// displays it in increments of days.
service.FailCountResetTime = 60*60*24*4; // Wait four days to reset counter

// The fail reboot message is used when a reboot action is specified and works in 
// conjunction with the RecoverAction.Reboot type.
service.FailRebootMsg = "Starting Service " + service.ServiceName + " failed. Now reboot compputer.";

// The fail run command is used to spawn another process when this service fails
service.FailRunCommand = "doCommand.exe";

// Do note that if you specify less than three actions, the remaining actions will take on
// the value of the last action. For example, if you only set one action to RunCommand,
// failure 2 and failure 3 will also take on the default action of RunCommand. Use
// RecoverAction.None to disable unwanted actions.
service.FailureActions.Add(new FailureAction(RecoverAction.Restart, 60000));
service.FailureActions.Add(new FailureAction(RecoverAction.RunCommand, 2000));
service.FailureActions.Add(new FailureAction(RecoverAction.None, 3000));


Namespace: uws.Install

Assembly: uwsCore (in uwsCore.dll)

See Also

FailureAction Members | uws.Install Namespace | RecoverAction | ExtendedServiceInstaller