private void button1_Click(object sender, EventArgs e) { var rnd = new Random(); var taskList = new TaskList(); for (var i = 0; i < 100; i++) { var s = rnd.Next(10); var j = i; var testTask = new Action(() => { Console.WriteLine(string.Format("第{0}个任务(用时{1}秒)已经开始", j, s)); Thread.Sleep(s * 1000); outStatus?.Invoke(j.ToString()); Console.WriteLine(string.Format("第{0}个任务(用时{1}秒)已经结束", j, s)); }); taskList.Tasks.Add(testTask); } taskList.Completed += () => Console.WriteLine("____________________没有更多的任务了!"); taskList.Start(); }