forked from Dasync/AsyncEnumerable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IAsyncEnumerable.cs
33 lines (31 loc) · 1.61 KB
/
IAsyncEnumerable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace System.Collections.Async
{
/// <summary>
/// Exposes an asynchronous enumerator, which supports a simple iteration over a non-generic collection
/// </summary>
public interface IAsyncEnumerable : IEnumerable
{
/// <summary>
/// Creates an enumerator that iterates through a collection asynchronously
/// </summary>
/// <param name="cancellationToken">A cancellation token to cancel creation of the enumerator in case if it takes a lot of time</param>
/// <returns>Returns a task with the created enumerator as result on completion</returns>
Task<IAsyncEnumerator> GetAsyncEnumeratorAsync(CancellationToken cancellationToken = default(CancellationToken));
}
/// <summary>
/// Exposes the asynchronous enumerator, which supports a simple iteration over a collection of typed items
/// </summary>
/// <typeparam name="T">The type of items in the collection</typeparam>
public interface IAsyncEnumerable<T> : IEnumerable<T>, IAsyncEnumerable
{
/// <summary>
/// Creates an enumerator that iterates through a collection asynchronously
/// </summary>
/// <param name="cancellationToken">A cancellation token to cancel creation of the enumerator in case if it takes a lot of time</param>
/// <returns>Returns a task with the created enumerator as result on completion</returns>
new Task<IAsyncEnumerator<T>> GetAsyncEnumeratorAsync(CancellationToken cancellationToken = default(CancellationToken));
}
}