Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            // 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);

            eventLog1.WriteEntry("In OnStart.");
            Thread.Sleep(10 * 1000);
            HttpClientSingleton.InitialiseInstance();

            // Build enrollment job
            EnrollmentJob enrollmentJob = new EnrollmentJob();

            enrollmentJob.RegisterListener(this);
            mNetworking.ExecuteAsync(enrollmentJob);

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