(66) c# async await

1.使用 async await

 

 

2.返回值

        static void Main(string[] args)
        {
            Program p = new Program();
            Console.WriteLine(1);
            p.Go();
            Console.WriteLine(2);
            Console.ReadLine();
        }

        async Task Go()
        {
            Console.WriteLine(3);
            await a();
            Console.WriteLine(4);
        }
        async Task a()
        {
            Console.WriteLine(5);
            int i = await b();
            Console.WriteLine(i);
        }
        async Task<int> b()
        {
            Console.WriteLine(6);
            await Task.Delay(5000);
            Console.WriteLine(7);
            int i = 999;
            return i;
        }

(66) c# async await

 2以后暂停几秒后继续执行

 

3.异步lambda表达式

 

(66) c# async await

上一篇:PHP imagick API中文简介


下一篇:Windows服务器安装consul