ThreadedCalculation.For<TParameter> Method (Int32, Int32, TParameter, ITrackCalculationProgress, ThreadedCalculation.BodyCallback<TParameter>) |
A 'for' loop that is parallelized among multiple threads according to the
ThreadingPolicy active in the calling thread.
The loop behaves as if written as
for (int i = start; i < stop; ++i).
Inside the
body callback, the
ThreadingPolicy will
be configured to use only the calling thread for any further parallelizable operations.
This usually improves performance by putting the parallelism where it is most useful:
in the 'for' loop itself. However, if you do wish to parallelize operations invoked
inside the 'for' loop, you must explicitly set the
ThreadingPolicy
inside the callback.
Namespace:
AGI.Foundation.Infrastructure.Threading
Assembly:
AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 25.1.421.0 (25.1.421.0)
Syntaxpublic static void For<TParameter>(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress tracker,
ThreadedCalculation.BodyCallback<TParameter> body
)
where TParameter : class
Public Shared Sub For(Of TParameter As Class) (
start As Integer,
stop As Integer,
parameter As TParameter,
tracker As ITrackCalculationProgress,
body As ThreadedCalculation.BodyCallback(Of TParameter)
)
public:
generic<typename TParameter>
where TParameter : ref class
static void For(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress^ tracker,
ThreadedCalculation.BodyCallback<TParameter>^ body
)
static member For :
start : int *
stop : int *
parameter : 'TParameter *
tracker : ITrackCalculationProgress *
body : ThreadedCalculation.BodyCallback<'TParameter> -> unit when 'TParameter : not struct
Parameters
- start
- Type: System.Int32
The start of the loop. - stop
- Type: System.Int32
The end of the loop. The body is NOT executed for this value.
- parameter
- Type: TParameter
A parameter that is passed to the body of the loop. If this instance implements
IThreadAware and IsThreadSafe returns
false, a copy of the parameter is made for each thread using
CopyForAnotherThread.
- tracker
- Type: AGI.Foundation.ITrackCalculationProgress
The object to which progress is reported and that is able to cancel this operation before it is complete, or null. - body
- Type: AGI.Foundation.Infrastructure.Threading.ThreadedCalculation.BodyCallback<TParameter>
The body of the loop.
Type Parameters
- TParameter
- The type of an instance that is passed to the body of the loop.
See Also