1
0

IAsyncEnumerator.cs 1.4 KB

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