ParallelHelperFor(Int32, Int32, ActionInt32) Method
Executes an indexed loop synchronously, in which iterations may run in parallel.
Namespace: KGySoft.ThreadingAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static void For(
int fromInclusive,
int toExclusive,
Action<int> body
)
Public Shared Sub For (
fromInclusive As Integer,
toExclusive As Integer,
body As Action(Of Integer)
)
public:
static void For(
int fromInclusive,
int toExclusive,
Action<int>^ body
)
static member For :
fromInclusive : int *
toExclusive : int *
body : Action<int> -> unit
Parameters
- fromInclusive Int32
- The start index, inclusive.
- toExclusive Int32
- The end index, exclusive.
- body ActionInt32
- The delegate that is invoked once per iteration.
This method is functionally the same as Parallel.For(int, int, Action<int>)
but it can be used even in .NET Framework 3.5.
If fromInclusive is greater than or equal to toExclusive, then the method returns without performing any iterations.
This method has no return type because if there was no exception, then the loop is guaranteed to be completed.
This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation or reporting progress.
Use the
ForT(T, Int32, Int32, ParallelConfig, ActionInt32) overload to adjust parallelization, set up cancellation, report progress;
or the
BeginForT(T, Int32, Int32, AsyncConfig, ActionInt32)/
ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32)
(in .NET Framework 4.0 and above) methods to do these asynchronously.