Sfoglia il codice sorgente

Improving compat MoveNext async extension method to honor cancellation.

Bart De Smet 8 anni fa
parent
commit
2d2ec8d939

+ 5 - 0
Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs

@@ -45,6 +45,11 @@ namespace System.Collections.Generic
         /// </returns>
         public static Task<bool> MoveNextAsync<T>(this IAsyncEnumerator<T> source, CancellationToken cancellationToken)
         {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            cancellationToken.ThrowIfCancellationRequested();
+
             return source.MoveNextAsync();
         }
     }