Esempio n. 1
0
        /// <summary>
        /// The Function starts the service
        /// </summary>
        /// <param name="args">The arguments that are given with the request of starting the service</param>
        protected override void OnStart(string[] args)
        {
            eventLog.WriteEntry("Start Pending");
            // 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);

            logging = new LoggingService();
            logging.MessageRecieved += Logging_MessageRecieved;
            eventLog.WriteEntry("LoggingService created.", (EventLogEntryType)LogMessageTypeEnum.INFO);

            m_imageServer = new ImageServer(logging, 5432);
            eventLog.WriteEntry("ImageServer created.", (EventLogEntryType)LogMessageTypeEnum.INFO);
            m_imageServer.StartServer();
            eventLog.WriteEntry("ImageServer started.", (EventLogEntryType)LogMessageTypeEnum.INFO);

            // Update the service state to Running.
            serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
            eventLog.WriteEntry("Running");
        }