예제 #1
0
        public static Task <T> FromCanceled <T>(this CancellationToken cancellationToken)
        {
            MiscellaneousUtils.Assert(cancellationToken.IsCancellationRequested);
#pragma warning disable CS8653 // A default expression introduces a null value for a type parameter.
            return(new Task <T>(() => default, cancellationToken));
예제 #2
0
 // From 4.6 on we could use Task.FromCanceled(), but we need an equivalent for
 // previous frameworks.
 public static Task FromCanceled(this CancellationToken cancellationToken)
 {
     MiscellaneousUtils.Assert(cancellationToken.IsCancellationRequested);
     return(new Task(() => {}, cancellationToken));
 }