IAsyncEnumerator.cs 1.3 KB

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