感受能夠用於log日誌的東西,這個東西他仍是會走的可是不會影響你下一步的操做,你下一步仍是正常怎麼操做就怎麼操做!異步
這樣能夠給用戶免掉一些不必的等待。async
static void Main(string[] args) { // 異步同步 Console.WriteLine("我是主線程,線程ID:{0}", Thread.CurrentThread.ManagedThreadId); //asd(); TaskMethod(); Console.WriteLine("Hello World!"); string str = Console.ReadLine(); Console.WriteLine(str); str = Console.ReadLine(); Console.WriteLine(str); str = Console.ReadLine(); Console.WriteLine(str); str = Console.ReadLine(); Console.WriteLine(str); Console.ReadLine(); } static async void TaskMethod() { await Task.Run(() => { Thread.Sleep(50000); }); Console.WriteLine(123); }