Use Task.FromCanceled<TResult>() on NETSTANDARD1_3
Task.FromCanceled<int>(cancellationToken) can be used on NETSTANDARD1_3 in TaskUtilities.GetCancelledZeroTask().
This commit is contained in:
parent
0a21b94609
commit
68f14c06cb
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
|||
case FrameStreamState.Open:
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return TaskUtilities.GetCancelledZeroTask();
|
||||
return TaskUtilities.GetCancelledZeroTask(cancellationToken);
|
||||
}
|
||||
break;
|
||||
case FrameStreamState.Closed:
|
||||
|
|
|
|||
|
|
@ -26,12 +26,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Infrastructure
|
|||
#endif
|
||||
}
|
||||
|
||||
public static Task<int> GetCancelledZeroTask()
|
||||
public static Task<int> GetCancelledZeroTask(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
// Task<int>.FromCanceled doesn't return Task<int>
|
||||
#if NETSTANDARD1_3
|
||||
return Task.FromCanceled<int>(cancellationToken);
|
||||
#else
|
||||
var tcs = new TaskCompletionSource<int>();
|
||||
tcs.TrySetCanceled();
|
||||
return tcs.Task;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue