class TaskDelayTest
{
Stopwatch sw = new Stopwatch();

public void DoRun()
{
Console.WriteLine($"Caller:Before call.");
ShowDelayAsync();
//ShowDelay();
Console.WriteLine($"Caller:After call.");
}
private async void ShowDelayAsync()
{
sw.Start();
Console.WriteLine($" 延时前:{sw.ElapsedMilliseconds}");
await Task.Delay(1000); // 不会阻塞当前线程
Console.WriteLine($" 延时后:{sw.ElapsedMilliseconds}");
}

private async void ShowDelay()
{
sw.Start();
Console.WriteLine($" 延时前:{sw.ElapsedMilliseconds}");
await Task.Run(()=> Thread.Sleep(1000));
Console.WriteLine($" 延时后:{sw.ElapsedMilliseconds}");
}
}

class Program
{
static void Main()
{
TaskDelayTest test = new TaskDelayTest();
test.DoRun();

Console.ReadKey();
}
}

输出:

Caller:Before call.
延时前:0
Caller:After call.
延时后:1027



参考:

《图解教程》