ParallelHelperBeginFor(Int32, Int32, ActionInt32) Method
Begins to execute an indexed loop asynchronously, in which iterations may run in parallel.
Namespace: KGySoft.ThreadingAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static IAsyncResult BeginFor(
int fromInclusive,
int toExclusive,
Action<int> body
)
Public Shared Function BeginFor (
fromInclusive As Integer,
toExclusive As Integer,
body As Action(Of Integer)
) As IAsyncResult
public:
static IAsyncResult^ BeginFor(
int fromInclusive,
int toExclusive,
Action<int>^ body
)
static member BeginFor :
fromInclusive : int *
toExclusive : int *
body : Action<int> -> IAsyncResult
- fromInclusive Int32
- The start index, inclusive.
- toExclusive Int32
- The end index, exclusive.
- body ActionInt32
- The delegate that is invoked once per iteration.
IAsyncResultAn
IAsyncResult that represents the asynchronous operation, which could still be pending.
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.
This method adjusts the degree of parallelization automatically and does not support cancellation or reporting progress.
Use the
BeginForT(T, Int32, Int32, AsyncConfig, ActionInt32) overload to adjust parallelization, set up cancellation, report progress;
or the
ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) method if you target .NET Framework 4.0 or later.