C#基础之Async和Await 的异步编程
2021-03-21 14:24
标签:str min otn pre await task make soft return 官方文档地址:https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/async/ C#基础之Async和Await 的异步编程 标签:str min otn pre await task make soft return 原文地址:https://www.cnblogs.com/marshhu/p/11822275.htmlCoffee cup = PourCoffee();
Console.WriteLine("coffee is ready");
Task
static async Task Main(string[] args)
{
Coffee cup = PourCoffee();
Console.WriteLine("coffee is ready");
var eggsTask = FryEggsAsync(2);
var baconTask = FryBaconAsync(3);
var toastTask = MakeToastWithButterAndJamAsync(2);
var eggs = await eggsTask;
Console.WriteLine("eggs are ready");
var bacon = await baconTask;
Console.WriteLine("bacon is ready");
var toast = await toastTask;
Console.WriteLine("toast is ready");
Juice oj = PourOJ();
Console.WriteLine("oj is ready");
Console.WriteLine("Breakfast is ready!");
async Task
static async Task Main(string[] args)
{
Coffee cup = PourCoffee();
Console.WriteLine("coffee is ready");
var eggsTask = FryEggsAsync(2);
var baconTask = FryBaconAsync(3);
var toastTask = MakeToastWithButterAndJamAsync(2);
var allTasks = new List
下一篇:c# 创建socket连接辅助类
文章标题:C#基础之Async和Await 的异步编程
文章链接:http://soscw.com/index.php/essay/67204.html