Ошибка в приложении службы окон
я создал тему
RMSEmailReaderWindowServiceThread = new Thread(new ThreadStart(continuouslyThreadRunMethod)); ////start the thread RMSEmailReaderWindowServiceThread.Start();
я создал метод
public void continuouslyThreadRunMethod() { // we're going to wait 5 minutes between calls to CTASK, so // set the interval to 300000 milliseconds // (1000 milliseconds = 1 second, 5 * 60 * 1000 = 300000) int waitTime = 300000; // 5 minutes // this variable tracks how many milliseconds have gone by since // the last call to CTASK. Set it to zero to indicate we're // starting fresh //int elapsed = 0; // because we don't want to use 100% of the CPU, we will be // sleeping for 1 second between checks to see if it's time to // call CTASK ServiceController RMSEmailReaderStatus = new ServiceController("RMSEmailReader"); try { // check the status of the service.if service is stop mean thread have to stop //!(RMSEmailReaderStatus.Status.Equals("ServiceControllerStatus.Stopped")) while (true) { ClientServerConnection(); Thread.Sleep(waitTime); if (RMSEmailReaderStatus.Status.Equals("ServiceControllerStatus.Stopped")) this.OnStop(); }//while close }//try close //for thread exception catch (ThreadAbortException TAE) { // we want to eat the excetion because we don't care if the // thread has aborted since we probably did it on purpose by // stopping the service. //if exception is raised close the application RMSDotNetExceptionHistory RDEH_Record = new RMSDotNetExceptionHistory(); RDEH_Record.ModuleName = "EmailReader"; RDEH_Record.ExceptionCode = TAE.ToString(); RDEH_Record.ExceptionDescription = TAE.ToString(); RDEH_Record.ExceptionDateAndTime = DateTime.Now; RDEH_Record.AdditionalComments = "Continously Thread Run Method created an exceptions"; InsertARecordIntoRMSDotNetExceptionHistory(RDEH_Record); //Environment.Exit(0); }//catch close catch (Exception ex) { RMSDotNetExceptionHistory RDEH_Record = new RMSDotNetExceptionHistory(); RDEH_Record.ModuleName = "EmailReader"; RDEH_Record.ExceptionCode = ex.ToString(); RDEH_Record.ExceptionDescription = ex.ToString(); RDEH_Record.ExceptionDateAndTime = DateTime.Now; RDEH_Record.AdditionalComments = "Continously Thread Run Method created an exceptions"; InsertARecordIntoRMSDotNetExceptionHistory(RDEH_Record); } }//Continouslytheard run method close
Ошибка:-
Не удалось остановить обслуживание. System.NullReferenceException: ссылка на объект не установлена на экземпляр объекта.
в RMSEmailReader.RMSEmailReaderClass.То onStop()
в системе.Событий.Например.DeferredStop()
Jameel VM
в какой строке вы получили исключение?
kalisiddayya
когда я останавливаю службу, появляется ошибка