private void LogRunTime(DateTime startTime, DateTime endTime) { try { ProcessScheduleDAL.UpdateRunTime(_serviceFid, startTime, endTime); } catch (Exception exception) { Logger.Instance.Error(this, exception); } }
/// <summary> /// 监控线程,响应用户界面对工作线程的停止、启动操作 /// </summary> protected void SystemMonitor() { Logger.Instance.Trace(this, "Entry SystemMonitor"); //int index = 0; // // 系统监控线程将一直运行直到WindowsService被结束 // while (isMonitorThreadActive) { //Infrustructure.Logger.Instance.Trace(this, string.Format("SystemMonitor loop {0}", (++index))); try { //读取系统记录 ProcessScheduleInfo SystemInfo = ProcessScheduleDAL.GetInfo(_serviceFid); InitialWithConfig(SystemInfo); WorkInDuration(SystemInfo); } catch (Exception exception) { Logger.Instance.Error(this, exception); Logger.Instance.Info(this, "由于错误停止了工作线程"); #region Modify: Andy-Liu 2008-11-06 执行错误时,停止工作线程 //停止工作线程 if (isWorkThreadActive) { StopWorkThread(); } #endregion } System.Threading.Thread.Sleep(_monitorWaitTime); } //如果监控线程被结束,那么工作线程也要结束 if (isWorkThreadActive) { StopWorkThread(); } Logger.Instance.Trace(this, "end SystemMonitor"); }