private void button2_Click(object sender, RoutedEventArgs e) { try { string chargeNamer = ""; string nameUse = "示例任务1"; if (chargeNamer.Length > nameUse.Length) { chargeNamer = chargeNamer.Substring(0, nameUse.Length); } else if (chargeNamer.Length < nameUse.Length) { chargeNamer += ("XXXXXXXXXXXXXX".Substring(0, nameUse.Length - chargeNamer.Length)); } Console.Write(chargeNamer); int timeLonger = 10; int deadLiner = 12; int circleTimer = 12; int timesr = 2; int startTimer = 2; //// int CPUindex = getCPUIndexCanUse(); charge newChargeForBook = new charge(timeLonger, circleTimer, deadLiner, timesr, startTimer, chargeNamer, theControlers[CPUindex], isAValuableCharge); newChargeForBook.theMainWindow = this; theControlers[CPUindex].chargesBook.Add(newChargeForBook); ListBoxItem f = new ListBoxItem(); f.Content = newChargeForBook.getShortInformation(); //AllChargeBook.Items.Add(f); //// for (int k = 0; k < theControlers.Count; k++) { float checker = 0; for (int i = 0; i < theControlers[k].chargesBook.Count; i++) { checker += theControlers[k].chargesBook[i].getCheckValue(); } if (checker > 1)//检查出错了 { MessageBox.Show("checker:" + checker + " 其实,这是不可调度的。\n请点击容错来排除这个问题。"); flashWindow(); } if (theControlers[k].schedulingMode == 2) //RM的特殊性 { theControlers[k].theSort(); //排序 if (!this.checkForRM(theControlers[k].chargesBook)) { MessageBox.Show("RM算法不可调度,有超时现象发生。"); } } theControlers[k].makeChargeShower(); } } catch { MessageBox.Show("除了名字麻烦其他项都输入整型数字。"); } }
private void makeExample() { try { int CPUIndex = getCPUIndexCanUse(); charge newChargeForBook = new charge(5, 30, 29, 2, 1, "示例进程1", theControlers[CPUIndex], false); newChargeForBook.theMainWindow = this; theControlers[CPUIndex].chargesBook.Add(newChargeForBook); ListBoxItem f = new ListBoxItem(); f.Content = newChargeForBook.getShortInformation(); //AllChargeBook.Items.Add(f); CPUIndex = getCPUIndexCanUse(); newChargeForBook = new charge(8, 20, 18, 2, 2, "示例进程2", theControlers[CPUIndex], false); newChargeForBook.theMainWindow = this; theControlers[CPUIndex].chargesBook.Add(newChargeForBook); ListBoxItem f2 = new ListBoxItem(); f2.Content = newChargeForBook.getShortInformation(); //AllChargeBook.Items.Add(f2); CPUIndex = getCPUIndexCanUse(); newChargeForBook = new charge(6, 25, 25, 2, 3, "示例进程3", theControlers[CPUIndex], false); newChargeForBook.theMainWindow = this; theControlers[CPUIndex].chargesBook.Add(newChargeForBook); ListBoxItem f3 = new ListBoxItem(); f3.Content = newChargeForBook.getShortInformation(); //AllChargeBook.Items.Add(f3); for (int i = 0; i < theControlers.Count; i++) { theControlers[i].makeChargeShower(); if (theControlers[i].schedulingMode == 2) //RM的特殊性 { theControlers[i].theSort(); //排序 if (!this.checkForRM(theControlers[i].chargesBook)) { MessageBox.Show("RM算法不可调度,有超时现象发生。"); } } } } catch { Console.WriteLine("index error"); } }