本想用委托异步的 发现core平台不支持BeginInvoke了
/// <summary> /// 异步 /// </summary> public class asynchronous { public delegate Task asyns(string name); public void Action1() { Console.WriteLine("开始......."); Console.WriteLine("当前线程Id为:{0}",Thread.CurrentThread.ManagedThreadId); //Action<string> action = new Action<string>(asynAction1); Console.WriteLine("开始执行......."); for (int i = 0; i < 5; i++) { string name = string.Format("执行异步{0}", i); Task task = Task.Run(()=> Console.WriteLine("执行异步{0},当前线程为{1}", name, Thread.CurrentThread.ManagedThreadId)); //action.BeginInvoke(name, null, null);//core平台已经不支持该操作了 } } public static void asynAction1(string name) { Console.WriteLine("执行异步{0},当前线程为{1}",name,Thread.CurrentThread.ManagedThreadId); } }