extends ServiceBase
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.ServiceProcess; public class Service1 : System.ServiceProcess.ServiceBase { public Service1() { this.ServiceName = "MyFirstService"; } static void Main() { System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } protected override void OnStart(string[] args) { EventLog.WriteEntry( "Hello from MyFirstService" ); } protected override void OnStop() { EventLog.WriteEntry( "Goodbye from MyFirstService" ); } }