Browse Source

Improving compat MoveNext async extension method to honor cancellation.

Bart De Smet 8 years ago
parent
commit
2d2ec8d939
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs

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

@@ -45,6 +45,11 @@ namespace System.Collections.Generic
         /// </returns>
         /// </returns>
         public static Task<bool> MoveNextAsync<T>(this IAsyncEnumerator<T> source, CancellationToken cancellationToken)
         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();
             return source.MoveNextAsync();
         }
         }
     }
     }