Επεξεργασία

Κοινή χρήση μέσω


Parallel.ForAsync Method

Definition

Overloads

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

Executes a for loop in which iterations may run in parallel.

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

Executes a for loop in which iterations may run in parallel.

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

Executes a for loop in which iterations may run in parallel.

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

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

Executes a for loop in which iterations may run in parallel.

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

Type Parameters

T

Parameters

fromInclusive
T

The start index, inclusive.

toExclusive
T

The end index, exclusive.

parallelOptions
ParallelOptions

An object that configures the behavior of this operation.

body
Func<T,CancellationToken,ValueTask>

An asynchronous delegate that is invoked once per element in the data source.

Returns

A task that represents the entire for each operation.

Exceptions

The body argument is null.

Remarks

The operation will execute at most ProcessorCount operations in parallel.

Applies to

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

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

Executes a for loop in which iterations may run in parallel.

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

Type Parameters

T

Parameters

fromInclusive
T

The start index, inclusive.

toExclusive
T

The end index, exclusive.

body
Func<T,CancellationToken,ValueTask>

An asynchronous delegate that is invoked once per element in the data source.

Returns

A task that represents the entire for each operation.

Exceptions

The body argument is null.

Remarks

The operation will execute at most ProcessorCount operations in parallel.

Applies to

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

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

Executes a for loop in which iterations may run in parallel.

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

Type Parameters

T

Parameters

fromInclusive
T

The start index, inclusive.

toExclusive
T

The end index, exclusive.

cancellationToken
CancellationToken

A cancellation token that may be used to cancel the for each operation.

body
Func<T,CancellationToken,ValueTask>

An asynchronous delegate that is invoked once per element in the data source.

Returns

A task that represents the entire for each operation.

Exceptions

The body argument is null.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

The operation will execute at most ProcessorCount operations in parallel.

Applies to