Parallel.ForEachAsync 方法

定义

重载

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IAsyncEnumerable<TSource> ^ source, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IAsyncEnumerable<TSource>

可枚举的数据源。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

注解

该操作最多 ProcessorCount 并行执行操作。

适用于

ForEachAsync<TSource>(IEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : seq<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IEnumerable(Of TSource), body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IEnumerable<TSource>

可枚举的数据源。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

注解

该操作最多 ProcessorCount 并行执行操作。

适用于

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IAsyncEnumerable<TSource> ^ source, System::Threading::CancellationToken cancellationToken, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.CancellationToken * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), cancellationToken As CancellationToken, body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IAsyncEnumerable<TSource>

可枚举的数据源。

cancellationToken
CancellationToken

可用于取消操作的 for-each 取消标记。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

取消令牌已取消。 此异常存储在返回的任务中。

注解

该操作最多 ProcessorCount 并行执行操作。

适用于

ForEachAsync<TSource>(IAsyncEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IAsyncEnumerable<TSource> ^ source, System::Threading::Tasks::ParallelOptions ^ parallelOptions, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.Tasks.ParallelOptions parallelOptions, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.Tasks.ParallelOptions * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), parallelOptions As ParallelOptions, body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IAsyncEnumerable<TSource>

可枚举的数据源。

parallelOptions
ParallelOptions

一个对象,用于配置此操作的行为。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

适用于

ForEachAsync<TSource>(IEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IEnumerable<TSource> ^ source, System::Threading::CancellationToken cancellationToken, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : seq<'Source> * System.Threading.CancellationToken * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IEnumerable(Of TSource), cancellationToken As CancellationToken, body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IEnumerable<TSource>

可枚举的数据源。

cancellationToken
CancellationToken

可用于取消操作的 for-each 取消标记。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

取消令牌已取消。 此异常存储在返回的任务中。

注解

该操作最多 ProcessorCount 并行执行操作。

适用于

ForEachAsync<TSource>(IEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)

Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs
Source:
Parallel.ForEachAsync.cs

IEnumerable<T> 执行一个for-each操作,其中迭代可以并行运行。

public:
generic <typename TSource>
 static System::Threading::Tasks::Task ^ ForEachAsync(System::Collections::Generic::IEnumerable<TSource> ^ source, System::Threading::Tasks::ParallelOptions ^ parallelOptions, Func<TSource, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForEachAsync<TSource> (System.Collections.Generic.IEnumerable<TSource> source, System.Threading.Tasks.ParallelOptions parallelOptions, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body);
static member ForEachAsync : seq<'Source> * System.Threading.Tasks.ParallelOptions * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> -> System.Threading.Tasks.Task
Public Shared Function ForEachAsync(Of TSource) (source As IEnumerable(Of TSource), parallelOptions As ParallelOptions, body As Func(Of TSource, CancellationToken, ValueTask)) As Task

类型参数

TSource

源中数据的类型。

参数

source
IEnumerable<TSource>

可枚举的数据源。

parallelOptions
ParallelOptions

一个对象,用于配置此操作的行为。

body
Func<TSource,CancellationToken,ValueTask>

数据源中每个元素调用一次的异步委托。

返回

表示整个 for-each 操作的任务。

例外

sourcebodynull

适用于