Parallel.ForEachAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ForEachAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IAsyncEnumerable<TSource>
An enumerable data source.
- body
- Func<TSource,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
source
or body
is null
.
Remarks
The operation will execute at most ProcessorCount operations in parallel.
Applies to
ForEachAsync<TSource>(IEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IEnumerable<TSource>
An enumerable data source.
- body
- Func<TSource,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
source
or body
is null
.
Remarks
The operation will execute at most ProcessorCount operations in parallel.
Applies to
ForEachAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IAsyncEnumerable<TSource>
An enumerable data source.
- cancellationToken
- CancellationToken
A cancellation token that may be used to cancel the for-each
operation.
- body
- Func<TSource,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
source
or body
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
ForEachAsync<TSource>(IAsyncEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IAsyncEnumerable<TSource>
An enumerable data source.
- parallelOptions
- ParallelOptions
An object that configures the behavior of this operation.
- body
- Func<TSource,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
source
or body
is null
.
Applies to
ForEachAsync<TSource>(IEnumerable<TSource>, CancellationToken, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IEnumerable<TSource>
An enumerable data source.
- cancellationToken
- CancellationToken
A cancellation token that may be used to cancel the for-each
operation.
- body
- Func<TSource,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
source
or body
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
ForEachAsync<TSource>(IEnumerable<TSource>, ParallelOptions, Func<TSource,CancellationToken,ValueTask>)
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
- Source:
- Parallel.ForEachAsync.cs
Executes a for-each
operation on an IEnumerable<T> in which iterations may run in parallel.
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
Type Parameters
- TSource
The type of the data in the source.
Parameters
- source
- IEnumerable<TSource>
An enumerable data source.
- parallelOptions
- ParallelOptions
An object that configures the behavior of this operation.
- body
- Func<TSource,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
source
or body
is null
.