Parallel.ForAsync 方法

定义

重载

ForAsync<T>(T, T, ParallelOptions, Func<T,CancellationToken,ValueTask>)

执行 for 循环,其中迭代可以并行运行。

ForAsync<T>(T, T, Func<T,CancellationToken,ValueTask>)

执行 for 循环,其中迭代可以并行运行。

ForAsync<T>(T, T, CancellationToken, Func<T,CancellationToken,ValueTask>)

执行 for 循环,其中迭代可以并行运行。

ForAsync<T>(T, T, ParallelOptions, Func<T,CancellationToken,ValueTask>)

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

执行 for 循环,其中迭代可以并行运行。

public:
generic <typename T>
 where T : System::Numerics::IBinaryInteger<T> static System::Threading::Tasks::Task ^ ForAsync(T fromInclusive, T toExclusive, System::Threading::Tasks::ParallelOptions ^ parallelOptions, Func<T, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForAsync<T> (T fromInclusive, T toExclusive, System.Threading.Tasks.ParallelOptions parallelOptions, Func<T,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body) where T : System.Numerics.IBinaryInteger<T>;
static member ForAsync : 'T * 'T * System.Threading.Tasks.ParallelOptions * Func<'T, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask (requires 'T :> System.Numerics.IBinaryInteger<'T>)> -> System.Threading.Tasks.Task (requires 'T :> System.Numerics.IBinaryInteger<'T>)
Public Shared Function ForAsync(Of T As IBinaryInteger(Of T)) (fromInclusive As T, toExclusive As T, parallelOptions As ParallelOptions, body As Func(Of T, CancellationToken, ValueTask)) As Task

类型参数

T

参数

fromInclusive
T

开始索引(含)。

toExclusive
T

结束索引(不含)。

parallelOptions
ParallelOptions

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

body
Func<T,CancellationToken,ValueTask>

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

返回

表示每个操作的整个任务。

例外

body 参数为 null

注解

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

适用于

ForAsync<T>(T, T, Func<T,CancellationToken,ValueTask>)

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

执行 for 循环,其中迭代可以并行运行。

public:
generic <typename T>
 where T : System::Numerics::IBinaryInteger<T> static System::Threading::Tasks::Task ^ ForAsync(T fromInclusive, T toExclusive, Func<T, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForAsync<T> (T fromInclusive, T toExclusive, Func<T,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body) where T : System.Numerics.IBinaryInteger<T>;
static member ForAsync : 'T * 'T * Func<'T, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask (requires 'T :> System.Numerics.IBinaryInteger<'T>)> -> System.Threading.Tasks.Task (requires 'T :> System.Numerics.IBinaryInteger<'T>)
Public Shared Function ForAsync(Of T As IBinaryInteger(Of T)) (fromInclusive As T, toExclusive As T, body As Func(Of T, CancellationToken, ValueTask)) As Task

类型参数

T

参数

fromInclusive
T

开始索引(含)。

toExclusive
T

结束索引(不含)。

body
Func<T,CancellationToken,ValueTask>

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

返回

表示每个操作的整个任务。

例外

body 参数为 null

注解

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

适用于

ForAsync<T>(T, T, CancellationToken, Func<T,CancellationToken,ValueTask>)

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

执行 for 循环,其中迭代可以并行运行。

public:
generic <typename T>
 where T : System::Numerics::IBinaryInteger<T> static System::Threading::Tasks::Task ^ ForAsync(T fromInclusive, T toExclusive, System::Threading::CancellationToken cancellationToken, Func<T, System::Threading::CancellationToken, System::Threading::Tasks::ValueTask> ^ body);
public static System.Threading.Tasks.Task ForAsync<T> (T fromInclusive, T toExclusive, System.Threading.CancellationToken cancellationToken, Func<T,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> body) where T : System.Numerics.IBinaryInteger<T>;
static member ForAsync : 'T * 'T * System.Threading.CancellationToken * Func<'T, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask (requires 'T :> System.Numerics.IBinaryInteger<'T>)> -> System.Threading.Tasks.Task (requires 'T :> System.Numerics.IBinaryInteger<'T>)
Public Shared Function ForAsync(Of T As IBinaryInteger(Of T)) (fromInclusive As T, toExclusive As T, cancellationToken As CancellationToken, body As Func(Of T, CancellationToken, ValueTask)) As Task

类型参数

T

参数

fromInclusive
T

开始索引(含)。

toExclusive
T

结束索引(不含)。

cancellationToken
CancellationToken

可用于取消每个操作的 取消标记。

body
Func<T,CancellationToken,ValueTask>

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

返回

表示每个操作的整个任务。

例外

body 参数为 null

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

注解

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

适用于