private GenericServiceThread InitializeThread(SystemProcessThread serviceThread) { GenericServiceThread thread = new GenericServiceThread(serviceThread.Name, userAccountId); thread.OnExecute += new GenericServiceThread.GOEventHandler(Execute); thread.OnSetStatusMessage += new GenericServiceThread.SetStatusMessageEventHandler(thread_OnSetStatusMessage); thread.OnReportEngineState += new GenericServiceThread.ReportEngineStateEventHandler(thread_OnReportEngineState); thread.OnSetEngineState += new GenericServiceThread.SetEngineStateEventHandler(thread_OnSetEngineState); thread.Init(false, serviceThread.SleepTime, serviceThread.Enabled); return(thread); }
private void Go(object sender, System.Timers.ElapsedEventArgs e) { //bool checkForNewThread = false; //if (ConfigurationManager.AppSettings["CheckForNewThread"] != null) // bool.TryParse(ConfigurationManager.AppSettings["CheckForNewThread"].ToString(), out checkForNewThread); processThreads = webClient.GetSystemProcessThreadsByProcessName(_systemProcess.Name); isRunning = true; if (_threads == null || _threads.Count == 0) { _threads = new List <GenericServiceThread>(); foreach (SystemProcessThread serviceThread in processThreads) { _threads.Add(InitializeThread(serviceThread)); } } else { //string systemProcess = string.Empty; //if (ConfigurationManager.AppSettings["SystemProcess"] != null) systemProcess = ConfigurationManager.AppSettings["SystemProcess"].ToString(); //_systemProcess = webClient.GetSystemProcessByName(systemProcess); foreach (SystemProcessThread systemProcessThread in processThreads) { if (_threads.Where(x => x.ThreadName.ToLower() == systemProcessThread.Name.ToLower()).Count() == 0) { _threads.Add(InitializeThread(systemProcessThread)); } } for (int i = 0; i < _threads.Count; i++) { GenericServiceThread serviceThread = _threads[i]; if (processThreads.Where(x => x.Name.ToLower() == serviceThread.ThreadName.ToLower()).Count() == 0) { _threads.Remove(serviceThread); i--; serviceThread.Dispose(); serviceThread = null; } } } }
void thread_OnReportEngineState(string threadName, GenericServiceThread.EngineStatusList state) { SystemProcessThread systemProcessThread = GetSystemProcessThread(threadName); if(systemProcessThread!=null) { systemProcessThread.Status = state.ToString(); UpdateSystemProcessThread(_OnUpdateSystemProcess(systemProcessThread)); } }
private GenericServiceThread InitializeThread(SystemProcessThread serviceThread) { GenericServiceThread thread = new GenericServiceThread(serviceThread.Name,userAccountId); thread.OnExecute += new GenericServiceThread.GOEventHandler(Execute); thread.OnSetStatusMessage += new GenericServiceThread.SetStatusMessageEventHandler(thread_OnSetStatusMessage); thread.OnReportEngineState += new GenericServiceThread.ReportEngineStateEventHandler(thread_OnReportEngineState); thread.OnSetEngineState += new GenericServiceThread.SetEngineStateEventHandler(thread_OnSetEngineState); thread.Init(false, serviceThread.SleepTime, serviceThread.Enabled); return thread; }