2 using System.Threading;
3 using System.Collections;
4 using System.ComponentModel;
6 using System.Diagnostics;
7 using System.ServiceProcess;
8 using System.Configuration.Install;
12 public class TechBotService : ServiceBase
14 private Thread thread;
15 private ServiceThread threadWorker;
17 public TechBotService()
19 InitializeComponents();
22 private void InitializeComponents()
24 this.ServiceName = "TechBot";
28 /// This method starts the service.
30 public static void Main()
32 System.ServiceProcess.ServiceBase.Run(new System.ServiceProcess.ServiceBase[] {
33 new TechBotService() // To run more than one service you have to add them here
38 /// Clean up any resources being used.
40 protected override void Dispose(bool disposing)
42 base.Dispose(disposing);
46 /// Start this service.
48 protected override void OnStart(string[] args)
52 threadWorker = new ServiceThread(EventLog);
53 thread = new Thread(new ThreadStart(threadWorker.Start));
55 EventLog.WriteEntry(String.Format("TechBot service is running."));
59 EventLog.WriteEntry(String.Format("Ex. {0}", ex));
64 /// Stop this service.
66 protected override void OnStop()
74 EventLog.WriteEntry(String.Format("TechBot service is stopped."));
78 EventLog.WriteEntry(String.Format("Ex. {0}", ex));