|
@@ -2,9 +2,7 @@
|
|
|
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
-using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
@@ -32,7 +30,6 @@ namespace System.Linq
|
|
|
source.ForEach(action, CancellationToken.None);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -40,8 +37,7 @@ namespace System.Linq
|
|
|
if (action == null)
|
|
|
throw new ArgumentNullException(nameof(action));
|
|
|
|
|
|
- source.ForEachAsync(action, cancellationToken)
|
|
|
- .Wait(cancellationToken);
|
|
|
+ source.ForEachAsync(action, cancellationToken).Wait(cancellationToken);
|
|
|
}
|
|
|
|
|
|
public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
|
|
@@ -51,8 +47,7 @@ namespace System.Linq
|
|
|
if (action == null)
|
|
|
throw new ArgumentNullException(nameof(action));
|
|
|
|
|
|
- source.ForEachAsync(action, cancellationToken)
|
|
|
- .Wait(cancellationToken);
|
|
|
+ source.ForEachAsync(action, cancellationToken).Wait(cancellationToken);
|
|
|
}
|
|
|
|
|
|
public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
|
|
@@ -103,8 +98,7 @@ namespace System.Linq
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- while (await e.MoveNextAsync(cancellationToken)
|
|
|
- .ConfigureAwait(false))
|
|
|
+ while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
|
|
|
{
|
|
|
action(e.Current, checked(index++));
|
|
|
}
|
|
@@ -115,4 +109,4 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|