IAsyncEnumerable.cs 1.1 KB

12345678910111213141516171819202122232425
  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. // See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface
  5. // and the design rationale. (8/30/2017)
  6. using System.Threading;
  7. namespace System.Collections.Generic
  8. {
  9. /// <summary>
  10. /// Asynchronous version of the <see cref="IEnumerable{T}"/> interface, allowing elements of the enumerable sequence to be retrieved asynchronously.
  11. /// </summary>
  12. /// <typeparam name="T">Element type.</typeparam>
  13. public interface IAsyncEnumerable<out T>
  14. {
  15. /// <summary>
  16. /// Gets an asynchronous enumerator over the sequence.
  17. /// </summary>
  18. /// <param name="cancellationToken">Cancellation token used to cancel the enumeration.</param>
  19. /// <returns>Enumerator for asynchronous enumeration over the sequence.</returns>
  20. IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default);
  21. }
  22. }