private void button1_Click(object sender, EventArgs e) { ResetAllObjects(); ReadJobFromFile(); while (true) { System.Threading.Thread.Sleep(DelayTime); if (_processList.Count == 0) { break; } var p = GetProcess(); if (p == null) { if (_processList.Count == 0) { break; } ChangeCurrentTime(); continue; } if (CurrentTime < p.Starttime) { CurrentTime = p.Starttime; } DoneJobLog tmp = new DoneJobLog(); tmp.Start = CurrentTime; tmp.Processname = p.Name; tmp.PrintColor = p.PrintColor; var currentTime = CurrentTime; p.DoJob(ref currentTime); CurrentTime = currentTime; tmp.End = currentTime; if (CheckProcessField() != "") { tmp.Hint = CheckProcessField(); } listBox2.Items.Add(tmp.Processname); listBox2.SelectedIndex = listBox2.Items.Count - 1; _joblog.Add(tmp); Refresh(); if (tmp.Hint != null) { break; } } HistoryofCurrentTime = CurrentTime; groupBox3.Visible = true; }
private void button1_Click(object sender, EventArgs e) { Timer t1 = new Timer { Interval = 1000 }; t1.Tick += timer1_Tick; t1.Enabled = true; t1.Start(); ResetAllObjects(); SliceTime = Convert.ToInt32(textBox1.Text); ContextSwitchTime = Convert.ToInt32(textBox2.Text); DelayTime = Convert.ToInt32(textBox3.Text); ReadJobFromFile(); while (true) { System.Threading.Thread.Sleep(DelayTime); if (_processQueue.Count == 0) { break; } var p = (Process)_processQueue.Dequeue(); DoneJobLog tmp = new DoneJobLog(); tmp.Start = CurrentTime; tmp.Processname = p.Name; var currentTime = CurrentTime; p.DoJob(ref currentTime); CurrentTime = currentTime; tmp.End = currentTime; listBox2.Items.Add(tmp.Processname); listBox2.SelectedIndex = listBox2.Items.Count - 1; _joblog.Add(tmp); if (p.Remaintime > SliceTime) { _processQueue.Enqueue(p); } else { _doneJob.Enqueue(p); listBox1.Items.Add(p.Name); listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox5.Items.Add(p.GetWaitTime().ToString()); } Refresh(); CurrentTime += ContextSwitchTime; listBox3.Items.Clear(); for (int i = 0; i < _processQueue.Count; i++) { Process a = (Process)_processQueue.Dequeue(); listBox3.Items.Add($"processname = {a.Name} Runningtime= {a.Runningtime} RemainTime={a.Remaintime}"); _processQueue.Enqueue(a); } } t1.Enabled = false; t1.Stop(); HistoryofCurrentTime = CurrentTime; groupBox3.Visible = true; ComputeAvrageWaitingTime(); }