static void TaskMethed() { Task task = Task.Factory.StartNew(() => { Console.WriteLine("task开始执行"); new Task(() => { Console.WriteLine("task1执行"); }, TaskCreationOptions.AttachedToParent).Start(); new Task(() => { Console.WriteLine("task2执行"); }, TaskCreationOptions.AttachedToParent).Start(); }, TaskCreationOptions.LongRunning).ContinueWith(p => { Console.WriteLine("task执行结束"); TaskMethed(); }); }
标签:Task,Console,C#,TaskCreationOptions,task,WriteLine,执行,循环 From: https://www.cnblogs.com/5tomorrow/p/16601579.html