标签:线程 [] 属性 分享 代码示例 工作 sleep pre ati
static void Main(string[] args) { Task t = Task.Run(() => { Thread.Sleep(500); Console.WriteLine("Lance"); Thread.Sleep(500); }); Console.WriteLine("t.IsCompleted=" + t.IsCompleted); t.Wait(); Console.WriteLine("t.IsCompleted=" + t.IsCompleted); }
运行结果:
static void Main(string[] args) { Task t = Task.Run(() => { Thread.Sleep(500); Console.WriteLine("Lance"); Thread.Sleep(500); }); Console.WriteLine("t.IsCompleted=" + t.IsCompleted); bool IsComplate= t.Wait(200); Console.WriteLine("wait 200毫秒后 t.IsCompleted=" + t.IsCompleted); Thread.Sleep(1000); Console.WriteLine("t.IsCompleted=" + t.IsCompleted); }
标签:线程 [] 属性 分享 代码示例 工作 sleep pre ati
原文地址:http://www.cnblogs.com/clc2008/p/6978786.html