using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; namespace ConsoleApplication3 { class { static { Console.WriteLine($”主程序头,当前线程ID:{Thread.CurrentThread.ManagedThreadId}“); CallSayHiAysnc(“Jack”); Console.WriteLine($”主程序尾,当前线程ID:{Thread.CurrentThread.ManagedThreadId}“); Console.ReadKey(); } static { Console.WriteLine($”异步调用头,当前线程ID:{Thread.CurrentThread.ManagedThreadId}“); string result = await SayHiAsync(name); Console.WriteLine($”异步调用尾,当前线程ID:{Thread.CurrentThread.ManagedThreadId}“); Console.WriteLine(result); } static { return } static { Thread.Sleep(10000); Console.WriteLine($”SayHi已执行,当前线程ID:{Thread.CurrentThread.ManagedThreadId}“); return } } } |