这对我来说似乎不直观:
var cts = new CancellationTokenSource();
cts.Cancel();
var tcs = new TaskCompletionSource<int>();
try
{
tcs.Task.Wait(cts.Token);
}
catch (OperationCanceledException)
{
Console.WriteLine(tcs.Task.Status); //TaskStatus.WaitingForActivation
}
我希望它将状态更新为TaskStatus.Canceled
. 留下它的理由是什么TaskStatus.WaitingForActivation
?