Op Englesch liesen Editéieren

Deelen iwwer


Task.WhenEach Method

Definition

Overloads

WhenEach(IEnumerable<Task>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach(ReadOnlySpan<Task>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach(Task[])

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach<TResult>(IEnumerable<Task<TResult>>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach<TResult>(ReadOnlySpan<Task<TResult>>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach<TResult>(Task<TResult>[])

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

WhenEach(IEnumerable<Task>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task> WhenEach(System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task> tasks);

Parameters

tasks
IEnumerable<Task>

The tasks to iterate through as they complete.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10

WhenEach(ReadOnlySpan<Task>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task> WhenEach(scoped ReadOnlySpan<System.Threading.Tasks.Task> tasks);
C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task> WhenEach(ReadOnlySpan<System.Threading.Tasks.Task> tasks);

Parameters

tasks
ReadOnlySpan<Task>

The tasks to iterate through as they complete.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10

WhenEach(Task[])

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task> WhenEach(params System.Threading.Tasks.Task[] tasks);

Parameters

tasks
Task[]

The task to iterate through when completed.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Exceptions

tasks is null.

tasks contains a null.

Remarks

The supplied tasks will become available to be output via the enumerable once they've completed. The exact order in which the tasks will become available is not defined.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10

WhenEach<TResult>(IEnumerable<Task<TResult>>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task<TResult>> WhenEach<TResult>(System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<TResult>> tasks);

Type Parameters

TResult

The type of the result returned by the tasks.

Parameters

tasks
IEnumerable<Task<TResult>>

The tasks to iterate through as they complete.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10

WhenEach<TResult>(ReadOnlySpan<Task<TResult>>)

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task<TResult>> WhenEach<TResult>(scoped ReadOnlySpan<System.Threading.Tasks.Task<TResult>> tasks);
C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task<TResult>> WhenEach<TResult>(ReadOnlySpan<System.Threading.Tasks.Task<TResult>> tasks);

Type Parameters

TResult

The type of the result returned by the tasks.

Parameters

tasks
ReadOnlySpan<Task<TResult>>

The tasks to iterate through as they complete.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10

WhenEach<TResult>(Task<TResult>[])

Creates an IAsyncEnumerable<T> that will yield the supplied tasks as those tasks complete.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Threading.Tasks.Task<TResult>> WhenEach<TResult>(params System.Threading.Tasks.Task<TResult>[] tasks);

Type Parameters

TResult

The type of the result returned by the tasks.

Parameters

tasks
Task<TResult>[]

The tasks to iterate through as they complete.

Returns

An IAsyncEnumerable<T> for iterating through the supplied tasks.

Applies to

.NET 10 a .NET 9
Produkt Versiounen
.NET 9, 10