namespace 异步编程
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("mian this is async{0}", Thread.CurrentThread.ManagedThreadId);
Do();
Console.WriteLine("mian end this is async{0}", Thread.CurrentThread.ManagedThreadId);
Console.ReadKey();
}
private async static void Do()
{
Console.WriteLine("start this is async do {0}", Thread.CurrentThread.ManagedThreadId);
await Task.Run(() =>
{
Thread.Sleep(1000);
Console.WriteLine("run this is async do {0}", Thread.CurrentThread.ManagedThreadId);
});
Console.WriteLine("end this is async do {0}", Thread.CurrentThread.ManagedThreadId);
}
}
}
原文:https://www.cnblogs.com/bruce1992/p/14082788.html