瀏覽代碼

Implement IsEmpty directly.

Bart De Smet 6 年之前
父節點
當前提交
89ec92be8b
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs

+ 4 - 1
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs

@@ -19,7 +19,10 @@ namespace System.Linq
 
             static async Task<bool> Core(IAsyncEnumerable<TSource> _source, CancellationToken _cancellationToken)
             {
-                return !await _source.AnyAsync(_cancellationToken).ConfigureAwait(false);
+                await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false))
+                {
+                    return !await e.MoveNextAsync();
+                }
             }
         }
     }