我在LINQPad中运行以下代码:
void Main()
{
Task x = TestAsync();
do
{
Thread.Sleep(200);
Console.WriteLine(x.Status);
} while (x.Status != TaskStatus.RanToCompletion);
}
public async static Task TestAsync()
{
await Task.Delay(1000);
return;
}
输出结果为:
WaitingForActivation
WaitingForActivation
WaitingForActivation
WaitingForActivation
RanToCompletion
为什么直接从WaitingForActivation
转到RanToCompletion
?为什么它显然永远不会处于Running
状态?