AsyncEnumerator.cs 983 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using System.Threading;
  6. namespace System.Collections.Generic
  7. {
  8. public static class AsyncEnumerator
  9. {
  10. /// <summary>
  11. /// Advances the enumerator to the next element in the sequence, returning the result asynchronously.
  12. /// </summary>
  13. /// <returns>
  14. /// Task containing the result of the operation: true if the enumerator was successfully advanced
  15. /// to the next element; false if the enumerator has passed the end of the sequence.
  16. /// </returns>
  17. public static Task<bool> MoveNext<T>(this IAsyncEnumerator<T> enumerator)
  18. {
  19. if (enumerator == null)
  20. throw new ArgumentNullException("enumerator");
  21. return enumerator.MoveNext(CancellationToken.None);
  22. }
  23. }
  24. }