private void Service_mission() { try { while (true) { if (_isLoadingAppService) { //stop => start if (_optionsAttribute.chkAutoRestart_flag) { foreach (var sourceitem in _appServiceSource) { if (sourceitem.StatusColor == Color.Red && sourceitem.Type.Equals("S")) { _details.ServiceStart(sourceitem.Name); _lg.Start(sourceitem.Name + " was restarted."); } else if (sourceitem.StatusColor == Color.Red && sourceitem.Type.Equals("A")) { _details.AppStart(sourceitem.FilePath); _lg.Start(sourceitem.Name + " was restarted."); } } } //Memory start => stop if (_optionsAttribute.chkAutoRestart_Memory_flag) { foreach (var sourceitem in _appServiceSource) { if (sourceitem.StatusColor == Color.LightGreen) { if (Double.Parse(sourceitem.MemoryUsed) > Double.Parse(sourceitem.MemoryLimit) && sourceitem.Type.Equals("S")) { _lg.Start(sourceitem.Name + " is out of the memory limit range! It will be stopped."); _details.ServiceStop(sourceitem.Name); } else if (Double.Parse(sourceitem.MemoryUsed) > Double.Parse(sourceitem.MemoryLimit) && sourceitem.Type.Equals("A")) { _lg.Start(sourceitem.Name + " is out of the memory limit range! It will be stopped."); _details.AppStop(sourceitem.Name); } } } } //ShutdownTime start => stop if (_optionsAttribute.chkAutoShutdown_flag) { foreach (var sourceitem in _appServiceSource) { if (sourceitem.StatusColor == Color.LightGreen) { if ((DateTime.Compare(DateTime.Now, sourceitem.ShutDownTime) > 0) && sourceitem.Type.Equals("S")) { _lg.Start(sourceitem.Name + " is time to be stopped."); _details.ServiceStop(sourceitem.Name); //Next Time sourceitem.ShutDownTime = sourceitem.ShutDownTime.AddDays(double.Parse(sourceitem.RestartDay)); } else if ((DateTime.Compare(DateTime.Now, sourceitem.ShutDownTime) > 0) && sourceitem.Type.Equals("A")) { _lg.Start(sourceitem.Name + " is time to be stopped."); _details.AppStop(sourceitem.Name); //Next Time sourceitem.ShutDownTime = sourceitem.ShutDownTime.AddDays(double.Parse(sourceitem.RestartDay)); } } } } ShowTime(UpdateClock_Service); var completeWebSource = _details.GetAppServiceExternalInfoAppServiceSources(_appServiceSource); _appServiceSource = completeWebSource; ResultShowAppServiceList(_appServiceSource); } Thread.Sleep(_optionsAttribute.serviceThreadSleep * 1000); } } catch (Exception e) { _lg.Start("Thread Service_mission:" + e.Message.ToString()); } }