共用方式為


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>)

來源:
Parallel.ForEachAsync.cs
來源:
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>)

來源:
Parallel.ForEachAsync.cs
來源:
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>)

來源:
Parallel.ForEachAsync.cs
來源:
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

適用於