Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static method: void ExecuteAsService(Action, Action, Action, Func<PowerBroadcastStatus, bool>)

Declaration

public static void ExecuteAsService(
    Action onStart,
    Action onStop = null,
    Action onShutdown = null,
    Func<PowerBroadcastStatus, bool> onPowerEvent = null
)

Summary

Passes control to the service manager, and configures callbacks to be used by the service manager in response to various events. This method must be called when the process is invoked with command line arguments specified in SingleSelfService.Install(string, string, string, string, ServiceStartMode, ServiceAccount, string, string, IList<string>). Does not return (unless called outside of SCM control, in which case it shows a generic error message and terminates the process).

Parameters

ActiononStart Invoked when the service is started.
ActiononStop Invoked when the service is stopped. Optional.
ActiononShutdown Invoked when the system is shutting down. Optional.
Func<PowerBroadcastStatus, bool>onPowerEvent Invoked on a power status change event. Optional. For more information, see ServiceBase.OnPowerEvent.