Show / Hide Table of Contents

    Class WindowsService

    Class which allows to start application as Windows service.

    Inheritance
    Object
    WindowsService
    Namespace: Nevatech.Vsb.Agent
    Assembly: Nevatech.Vsb.Agent.dll
    Syntax
    public class WindowsService : ServiceBase

    Constructors

    WindowsService()

    Initializes new instance.

    Declaration
    public WindowsService()

    Fields

    Name

    Gets the Agent Service default system name.

    Declaration
    public const string Name = "Nevatech.Vsb.Agent"
    Field Value
    Type Description
    String

    Methods

    Dispose(Boolean)

    Clean up any resources being used.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    True if managed resources should be disposed; otherwise, false.

    Install()

    Installs Agent Service and configure it to run under LocalSystem account and start automatically.

    Declaration
    public static void Install()

    Install(ServiceAccount, String, String, ServiceStartMode, String, String, String)

    Installs Agent Service on local machine.

    Declaration
    public static void Install(ServiceAccount accountType, string userName, string password, ServiceStartMode startMode, string logFileName, string serviceName = "Nevatech.Vsb.Agent", string parameters = null)
    Parameters
    Type Name Description
    ServiceAccount accountType

    Type of Windows account that will be used to execute this service.

    String userName

    If user account is used, specifies user name and domain of Windows user.

    String password

    If user account is used, specifies password of Windows user.

    ServiceStartMode startMode

    Specifies the start mode of the service.

    String logFileName

    Name of the file that will be used to write messages during installation process. If Null, no log file will be used.

    String serviceName

    System name of the service, if not default name is used.

    String parameters

    Command line arguments to be added to the service executable.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown, if service is being configured under user account and user name or password is not provided.

    InvalidOperationException

    Thrown, if service has already been installed on local machine.

    Install(String, String)

    Installs Agent Service and configure it to run under LocalSystem account and start automatically.

    Declaration
    public static void Install(string logFileName, string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    String logFileName

    Name of the file that will be used to write messages during installation process. If Null, no log file will be used.

    String serviceName

    System name of the service, if not default name is used.

    IsInstalled(String)

    Returns the flag that indicates, if Management Service is installed on the local machine.

    Declaration
    public static bool IsInstalled(string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    String serviceName

    System name of the service, if not default name is used.

    Returns
    Type Description
    Boolean

    True, if service has been installed. False, otherwise.

    IsStarted(String)

    Returns the flag that indicates, if Management Service is running on the local machine.

    Declaration
    public static bool IsStarted(string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    String serviceName

    System name of the service, if not default name is used.

    Returns
    Type Description
    Boolean

    True, if service is running. False, otherwise.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown, if service is not installed on local machine.

    OnStart(String[])

    Executes, when Start command is sent to the service by Windows Service Manager. Starts all configured service tasks.

    Declaration
    protected override void OnStart(string[] args)
    Parameters
    Type Name Description
    String[] args

    Not used.

    OnStop()

    Executes, when Stop command is sent to the service by Windows Service Manager. Stops all currently running service tasks.

    Declaration
    protected override void OnStop()

    Start(TimeSpan, String)

    Starts Agent Service Windows service.

    Declaration
    public static void Start(TimeSpan timeout, string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    TimeSpan timeout

    Specifies how long system should wait for service to start. If timeout expires, TimeoutException will be thrown.

    String serviceName

    System name of the service, if not default name is used.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown, if service is not installed on local machine.

    Stop(TimeSpan, String)

    Stops Agent Service Windows service.

    Declaration
    public static void Stop(TimeSpan timeout, string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    TimeSpan timeout

    Specifies how long system should wait for service to stop. If timeout expires, TimeoutException will be thrown.

    String serviceName

    System name of the service, if not default name is used.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown, if service is not installed on local machine.

    Uninstall()

    Uninstall Agent Service from local machine.

    Declaration
    public static void Uninstall()

    Uninstall(String, String)

    Uninstall Agent Service from local machine.

    Declaration
    public static void Uninstall(string logFileName, string serviceName = "Nevatech.Vsb.Agent")
    Parameters
    Type Name Description
    String logFileName

    Name of the file that will be used to write messages during uninstallation process. If Null, no log file will be used.

    String serviceName

    System name of the service, if not default name is used.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown, if service is not installed on local machine.

    Back to top Nevatech Sentinet 6.5 Online Documentation