在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { List<Task> taskList = new List<Task>(); taskList.Add( Task.Factory.StartNew(()=> { Thread.Sleep(1000); Console.WriteLine("1秒执行结束"); })); taskList.Add(Task.Factory.StartNew(() => { Thread.Sleep(800); Console.WriteLine("o.8秒执行结束"); })); Console.WriteLine("执行中"); TaskFactory taskFactory = new TaskFactory(); taskList.Add(taskFactory.ContinueWhenAll(taskList.ToArray(), tArray => { Thread.Sleep(200); Console.WriteLine("等待这些完成后执行"); })); //Console.WriteLine("执行完成"); Console.Read(); } } }
|
请发表评论