IAsyncEnumerator.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace System.Collections.Generic
  7. {
  8. /// <summary>
  9. /// Asynchronous version of the IEnumerator&lt;T&gt; interface, allowing elements to be
  10. /// retrieved asynchronously.
  11. /// </summary>
  12. /// <typeparam name="T">Element type.</typeparam>
  13. public interface IAsyncEnumerator<out T> : IDisposable
  14. {
  15. /// <summary>
  16. /// Gets the current element in the iteration.
  17. /// </summary>
  18. T Current { get; }
  19. /// <summary>
  20. /// Advances the enumerator to the next element in the sequence, returning the result asynchronously.
  21. /// </summary>
  22. /// <param name="cancellationToken">Cancellation token that can be used to cancel the operation.</param>
  23. /// <returns>
  24. /// Task containing the result of the operation: true if the enumerator was successfully advanced
  25. /// to the next element; false if the enumerator has passed the end of the sequence.
  26. /// </returns>
  27. Task<bool> MoveNextAsync(CancellationToken cancellationToken);
  28. }
  29. }