ParallelHelperForAsync(Int32, Int32, ActionInt32) Method
Executes 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 Task ForAsync(
int fromInclusive,
int toExclusive,
Action<int> body
)
Public Shared Function ForAsync (
fromInclusive As Integer,
toExclusive As Integer,
body As Action(Of Integer)
) As Task
public:
static Task^ ForAsync(
int fromInclusive,
int toExclusive,
Action<int>^ body
)
static member ForAsync :
fromInclusive : int *
toExclusive : int *
body : Action<int> -> Task
- fromInclusive Int32
- The start index, inclusive.
- toExclusive Int32
- The end index, exclusive.
- body ActionInt32
- The delegate that is invoked once per iteration.
TaskA
Task that represents the asynchronous operation, which could still be pending.
If fromInclusive is greater than or equal to toExclusive, then the operation completes synchronously without performing any iterations.
The Task returned by this method has no result because if there was no exception, then the loop is guaranteed to be completed.
This method adjusts the degree of parallelization automatically and does not support cancellation or reporting progress.
Use the
ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) overload to adjust parallelization, set up cancellation or to report progress.