Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            eventLog.WriteEntry(LogMessages.START_SERVICE, EventLogEntryType.Information, eventId++, EventCategories.SERVICE_EVENT);

            ServiceStatus serviceStatus = new ServiceStatus();
            serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
            serviceStatus.dwWaitHint = 100000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            //SqlConnection sqlConn = new SqlConnection(conString);
            eventLog.WriteEntry("Before Try", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);

            /*try
            {
                eventLog.WriteEntry("In try", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
                con.Open();
                eventLog.WriteEntry("Open Connection", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
            }
            catch (Exception ex)
            {
                eventLog.WriteEntry("Exception", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
                eventLog.WriteEntry(ex.Message, EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
            }*/

            InitializeTimer();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
        }
Exemplo n.º 2
0
 private static extern bool SetServiceStatus(IntPtr handle, ref ServiceStatus serviceStatus);