Universal Windows Service Class Library

Installer.FailureActions Property

Property to set the different failure actions.

public System.Collections.ArrayList FailureActions {get;}

Remarks

Property to set the different failure actions.

For further information of usage see the source code example below.

Example

Installer service = new Installer();

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));

See Also

Installer Class | uws Namespace | FailureAction | RecoverAction | ExtendedServiceInstaller