Sdílet prostřednictvím


PagedEnumerableExtensions.ForEachAsync Method

Definition

Overloads

ForEachAsync<T>(IPagedEnumerable<T>, Action<T>, CancellationToken)

Iterates over an IPagedEnumerable<T> sequence, invoking a synchronous delegate for each element.

ForEachAsync<T>(IPagedEnumerable<T>, Func<T,CancellationToken,Task>, CancellationToken)

Iterates over an IPagedEnumerable<T> sequence, invoking an asynchronous delegate for each element.

ForEachAsync<T>(IPagedEnumerable<T>, Func<T,Task>, CancellationToken)

Iterates over an IPagedEnumerable<T> sequence, invoking an asynchronous delegate for each element.

ForEachAsync<T>(IPagedEnumerable<T>, Action<T>, CancellationToken)

Source:
PagedEnumerableExtensions.cs

Iterates over an IPagedEnumerable<T> sequence, invoking a synchronous delegate for each element.

public static System.Threading.Tasks.Task ForEachAsync<T> (this Microsoft.Azure.Batch.IPagedEnumerable<T> source, Action<T> body, System.Threading.CancellationToken cancellationToken = default);
static member ForEachAsync : Microsoft.Azure.Batch.IPagedEnumerable<'T> * Action<'T> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ForEachAsync(Of T) (source As IPagedEnumerable(Of T), body As Action(Of T), Optional cancellationToken As CancellationToken = Nothing) As Task

Type Parameters

T

Parameters

source
IPagedEnumerable<T>

The IPagedEnumerable<T> to iterate over.

body
Action<T>

The delegate to execute for each element in source.

cancellationToken
CancellationToken

A CancellationToken for controlling the lifetime of the asynchronous operation.

Returns

A Task that represents the iteration operation. The task completes when iteration is complete.

Remarks

This method processes elements sequentially, not concurrently. That is, for each element in the sequence, the method completes execution of the delegate before processing the next element.

Applies to

ForEachAsync<T>(IPagedEnumerable<T>, Func<T,CancellationToken,Task>, CancellationToken)

Source:
PagedEnumerableExtensions.cs

Iterates over an IPagedEnumerable<T> sequence, invoking an asynchronous delegate for each element.

public static System.Threading.Tasks.Task ForEachAsync<T> (this Microsoft.Azure.Batch.IPagedEnumerable<T> source, Func<T,System.Threading.CancellationToken,System.Threading.Tasks.Task> body, System.Threading.CancellationToken cancellationToken = default);
static member ForEachAsync : Microsoft.Azure.Batch.IPagedEnumerable<'T> * Func<'T, System.Threading.CancellationToken, System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ForEachAsync(Of T) (source As IPagedEnumerable(Of T), body As Func(Of T, CancellationToken, Task), Optional cancellationToken As CancellationToken = Nothing) As Task

Type Parameters

T

Parameters

source
IPagedEnumerable<T>

The IPagedEnumerable<T> to iterate over.

body
Func<T,CancellationToken,Task>

The asynchronous delegate to execute for each element in source.

cancellationToken
CancellationToken

A CancellationToken for controlling the lifetime of the asynchronous operation.

Returns

A Task that represents the iteration operation. The task completes when iteration is complete.

Remarks

This method processes elements sequentially, not concurrently. That is, for each element in the sequence, the method awaits the asynchronous delegate before processing the next element.

Applies to

ForEachAsync<T>(IPagedEnumerable<T>, Func<T,Task>, CancellationToken)

Source:
PagedEnumerableExtensions.cs

Iterates over an IPagedEnumerable<T> sequence, invoking an asynchronous delegate for each element.

public static System.Threading.Tasks.Task ForEachAsync<T> (this Microsoft.Azure.Batch.IPagedEnumerable<T> source, Func<T,System.Threading.Tasks.Task> body, System.Threading.CancellationToken cancellationToken = default);
static member ForEachAsync : Microsoft.Azure.Batch.IPagedEnumerable<'T> * Func<'T, System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ForEachAsync(Of T) (source As IPagedEnumerable(Of T), body As Func(Of T, Task), Optional cancellationToken As CancellationToken = Nothing) As Task

Type Parameters

T

Parameters

source
IPagedEnumerable<T>

The IPagedEnumerable<T> to iterate over.

body
Func<T,Task>

The asynchronous delegate to execute for each element in source.

cancellationToken
CancellationToken

A CancellationToken for controlling the lifetime of the asynchronous operation.

Returns

A Task that represents the iteration operation. The task completes when iteration is complete.

Remarks

This method processes elements sequentially, not concurrently. That is, for each element in the sequence, the method awaits the asynchronous delegate before processing the next element.

Applies to