ParallelHelperBeginFor(Int32, Int32, ActionInt32) Method

Begins to execute an indexed loop asynchronously, in which iterations may run in parallel.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static IAsyncResult BeginFor(
	int fromInclusive,
	int toExclusive,
	Action<int> body
)

Parameters

fromInclusive  Int32
The start index, inclusive.
toExclusive  Int32
The end index, exclusive.
body  ActionInt32
The delegate that is invoked once per iteration.

Return Value

IAsyncResult
An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

In .NET Framework 4.0 and above you can use also the ForAsync(Int32, Int32, ActionInt32) method.

To get the result or the exception that occurred during the operation you have to call the EndFor method.

If fromInclusive is greater than or equal to toExclusive, then the operation completes synchronously without performing any iterations.

Exceptions

See Also