瀏覽代碼

Improving compat MoveNext async extension method to honor cancellation.

Bart De Smet 8 年之前
父節點
當前提交
2d2ec8d939
共有 1 個文件被更改,包括 5 次插入0 次删除
  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>
         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();
         }
     }