class InvokingAnAsynchronousTask { public static void Main() { const int repetitions = 1000; // Use Task.Factory.StartNew<string>() for // TPL prior to .NET 4.5 Task task = Task.Run(() => { for (int count = 0; count < repetitions; count++) { Console.Write('-'); } }); for (int count = 0; count < repetitions; count++) { Console.Write('+'); } // Wait until the Task completes task.Wait(); Console.WriteLine("主线程完成"); Console.ReadKey(); } }