async await 成对出现。执行结果为: end  async 

        static void Main(string[] args)
        {

            DoAsync();
            
            Console.WriteLine("end");

            Console.ReadLine();
        }

        private static async Task DoAsync()
        {
            string ss = await ReturnAsync();
            Console.WriteLine(ss);
        }

        private static async Task<string> ReturnAsync()
        {
            return await Task<string>.Run(() =>
            {
                Thread.Sleep(5000);
                return "async";
            });
        }

 

相关文章:

  • 2021-08-12
猜你喜欢
  • 2021-10-31
  • 2021-06-29
  • 2021-07-10
  • 2022-03-01
相关资源
相似解决方案