Implement the service interface
using System;
using System.Timers;
using System.ServiceProcess;
class MyService : ServiceBase
{
public MyService()
{
ServiceName = "My Service";
AutoLog = true;
CanStop = true;
CanPauseAndContinue = true;
CanHandleSessionChangeEvent = true;
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("MyService Service starting. ");
}
protected override void OnStop()
{
EventLog.WriteEntry("MyService Service stopping...");
}
protected override void OnPause()
{
EventLog.WriteEntry("MyService Service pausing...");
}
protected override void OnContinue()
{
EventLog.WriteEntry("MyService Service resuming...");
}
protected override void OnSessionChange(SessionChangeDescription change)
{
EventLog.WriteEntry("MyService Session change..." +
change.Reason);
}
public static void Main()
{
ServiceBase.Run(new MyService());
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
|