/// <summary> /// A function that is trigged when the service is started. /// First it logs the fact that is it starting up the service and also changes its status to SERVICE_START_PENDING /// After that, it logs the fact that the service was started and changes its status to SERVICE_RUNNING. /// </summary> /// <param name="args">The arguements given to the service on startup.</param> protected override void OnStart(string[] args) { eventLog1.WriteEntry("Starting ImageService."); // Update the service state to Start Pending. ServiceStatus ServiceStatus = new ServiceStatus(); ServiceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; ServiceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref ServiceStatus); //START IT UP HERE Logging = new LoggingService(); Logging.MessageRecieved += C_MessageRecieved; Communication.Server ComServer = Communication.Server.GetServer(); Server = new ImageServer(Logging); String[] Handelers = ConfigurationManager.AppSettings["Handler"].Split(';'); for (int i = 0; i < Handelers.Count(); i++) { Server.AddDirectory(Handelers[i]); } // Update the service state to Running. ServiceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref ServiceStatus); IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8000); ComServer.ServerStart(ep); eventLog1.WriteEntry("Started ImageService."); }