日期:2014-05-18 浏览次数:21083 次
namespace ConsoleApplication1
{
class Program
{
static Task ones;
static void Main(string[] args)
{
ones = new Task(one);
ones.Start();
Console.ReadKey();
}
static void one()
{
Console.WriteLine("任务ID: {0}",Task.CurrentId);
var twos = new Task(two);
twos.Start();
Console.WriteLine("任务一启动");
Thread.Sleep(2000);
}
static void two()
{
Console.WriteLine("任务二启动");
Thread.Sleep(2000);
ones= new Task(one);
ones.Start();
}
}
}