using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp5
{
internal class Program
{
static async Task Main(string[] args)
{
await ConsoleWriteLineSomethingAsync("A");//用了await会执行完输出A再往下走
Console.WriteLine("Break");
ConsoleWriteLineSomethingAsync("B");
ConsoleWriteLineSomethingAsync("C");
Console.ReadKey();
}
static async Task ConsoleWriteLineSomethingAsync(string value)
{
for(int i = 0; i < 10; i++)
{
Console.WriteLine(value);
//什么也不加会先全部输出完B再输出C
//await Task.Delay(500);//延时 BC会交错输出
//await Task.Yield();//用于让出控制权 BC会交错输出
}
}
}
}