/// <summary> /// 停止所有任务 /// </summary> public void StopAllJobs() { JobAgents.ForEach(j => { j.Stop(); }); while (!IsAllJobsStoped) { Thread.Sleep(1000); } }
/// <summary> /// 启动所有任务 /// </summary> public void StartAllJobs() { JobAgents.ForEach(j => { Task.Factory.StartNew(() => { var random = new Random(DateTime.Now.Millisecond); Thread.Sleep(random.Next(1000, 6000)); j.Start(true); }); Thread.Sleep(100); }); }