Example #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));
Example #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));
 }