Exemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="IAsyncEnumerable{T}"/> which will allow at most one <see cref="IAsyncEnumerator{T}"/> to be active at once.
 /// </summary>
 /// <typeparam name="T">The type of items being enumerated.</typeparam>
 /// <param name="startInfo">The <see cref="SequentialEnumerationStartInfo{T}"/> containing callbacks to use.</param>
 /// <param name="asyncProvider">The <see cref="IAsyncProvider"/> for the returned <see cref="IAsyncEnumerable{T}"/>.</param>
 /// <returns>A new instance of <see cref="IAsyncEnumerable{T}"/> which behaves like callbacks in <paramref name="startInfo"/> specified.</returns>
 public static IAsyncEnumerable <T> CreateExclusiveSequentialEnumerable <T>(
     SequentialEnumerationStartInfo <T> startInfo,
     IAsyncProvider asyncProvider
     ) => new AsyncEnumerableExclusive <T>(SequentialCurrentInfoFactory.GetInstance(startInfo.MoveNext, startInfo.Dispose), asyncProvider);
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="IAsyncEnumerator{T}"/> which fetches one item at a time using given callback.
 /// </summary>
 /// <typeparam name="T">The type of items being enumerated.</typeparam>
 /// <param name="moveNext">The callback for potentially asynchronously fetching next item.</param>
 /// <param name="dispose">The callback to dispose enumerator.</param>
 /// <returns>A new instance of <see cref="IAsyncEnumerator{T}"/> which behaves like <paramref name="moveNext"/> and <paramref name="dispose"/> specify.</returns>
 /// <remarks>
 /// The returned <see cref="IAsyncEnumerator{T}"/> will have guard code to prevent concurrent invocation.
 /// </remarks>
 public static IAsyncEnumerator <T> CreateSequentialEnumerator <T>(
     MoveNextAsyncDelegate <T> moveNext,
     EnumerationEndedDelegate dispose
     ) => new AsyncEnumerator <T>(SequentialCurrentInfoFactory.GetInstance(moveNext, dispose));