IAsyncEnumerator.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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.Threading.Tasks;
  4. using System.Threading;
  5. namespace System.Collections.Generic
  6. {
  7. /// <summary>
  8. /// Asynchronous version of the IEnumerator&lt;T&gt; interface, allowing elements to be
  9. /// retrieved asynchronously.
  10. /// </summary>
  11. /// <typeparam name="T">Element type.</typeparam>
  12. public interface IAsyncEnumerator<
  13. #if !NO_VARIANCE
  14. out
  15. #endif
  16. T> : IDisposable
  17. {
  18. /// <summary>
  19. /// Advances the enumerator to the next element in the sequence, returning the result asynchronously.
  20. /// </summary>
  21. /// <param name="cancellationToken">Cancellation token that can be used to cancel the operation.</param>
  22. /// <returns>
  23. /// Task containing the result of the operation: true if the enumerator was successfully advanced
  24. /// to the next element; false if the enumerator has passed the end of the sequence.
  25. /// </returns>
  26. Task<bool> MoveNext(CancellationToken cancellationToken);
  27. /// <summary>
  28. /// Gets the current element in the iteration.
  29. /// </summary>
  30. T Current { get; }
  31. }
  32. }