IAsyncEnumerable.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. #if !HAS_ASYNCENUMERABLE
  7. using System.Threading;
  8. namespace System.Collections.Generic
  9. {
  10. /// <summary>
  11. /// Asynchronous version of the <see cref="IEnumerable{T}"/> interface, allowing elements of the enumerable sequence to be retrieved asynchronously.
  12. /// </summary>
  13. /// <typeparam name="T">Element type.</typeparam>
  14. public interface IAsyncEnumerable<out T>
  15. {
  16. /// <summary>
  17. /// Gets an asynchronous enumerator over the sequence.
  18. /// </summary>
  19. /// <param name="cancellationToken">Cancellation token used to cancel the enumeration.</param>
  20. /// <returns>Enumerator for asynchronous enumeration over the sequence.</returns>
  21. IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default);
  22. }
  23. }
  24. #else
  25. using System.Runtime.CompilerServices;
  26. [assembly: TypeForwardedTo(typeof(System.Collections.Generic.IAsyncEnumerable<>))]
  27. #endif