ParallelHelperForAsync(Int32, Int32, TaskConfig, ActionInt32) Method

Executes an indexed loop asynchronously, in which iterations may run in parallel and the execution can be configured.
See the Remarks section of the ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) overload for details.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static Task<bool> ForAsync(
	int fromInclusive,
	int toExclusive,
	TaskConfig? asyncConfig,
	Action<int> body
)

Parameters

fromInclusive  Int32
The start index, inclusive.
toExclusive  Int32
The end index, exclusive.
asyncConfig  TaskConfig
An optional configuration to adjust parallelization or cancellation. This method does not report progress even if Progress is set in this parameter. To report progress use the ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) overload.
body  ActionInt32
The delegate that is invoked once per iteration.

Return Value

TaskBoolean
A task that represents the asynchronous operation. Its result is , if the operation completed successfully, or , if the operation has been canceled and ThrowIfCanceled in asyncConfig parameter was .

Exceptions

ArgumentNullExceptionbody is .
TaskCanceledExceptionThe operation has been canceled and ThrowIfCanceled in asyncConfig was . This exception is thrown when the result is awaited.

See Also