public void RunQueuer() { if (QueueList.Count > 0) { Working = true; _currentEntry = QueueList[0]; RunProgram(QueueList[0]); } }
public void RunProgram(ProgramEntry entry) { try { entry.Output = ""; entry.Working = true; entry.Process.Exited += _currentProcess_Exited; entry.StartProcess(_redirectOutput); entry.Status = "Running"; } catch (Exception e) { entry.Working = false; entry.Finished = false; entry.Status = string.Format("Error while starting: {0}", e.Message); entry.Output += string.Format("Error while starting {0}:\n\n{1}", entry.Name, e.ToString()); if (RunNext()) { _currentEntry = null; this.Working = false; } } }
private bool RunNext() { for (int i = 0; i < QueueList.Count; i++) { if (!QueueList[i].Finished && !QueueList[i].Working) { _currentEntry = QueueList[i]; RunProgram(_currentEntry); return false; } } return true; }
public EntryManager() { QueueList = new ObservableCollection<ProgramEntry>(); _currentEntry = null; _redirectOutput = true; }
void _currentProcess_Exited(object sender, EventArgs e) { string path = (sender as Process).StartInfo.FileName; ProgramEntry curr = null; foreach (var entry in QueueList) { if (entry.Process == sender as Process) { curr = entry; break; } } if (_redirectOutput) curr.ProcessManager.StopMonitoringProcessOutput(); curr.Working = false; curr.Finished = true; curr.Status = "Finished"; OnEntryFinish(curr, new EventArgs()); if (curr == _currentEntry) if (!this.Working) return; else if (RunNext()) { _currentEntry = null; this.Working = false; } }