ThreadedCalculationForTParameter Method (Int32, Int32, TParameter, ITrackCalculationProgress, ThreadedCalculationBodyCallbackTParameter) |
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: 24.3.420.0 (24.3.420.0)
Syntax public static void For<TParameter>(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress tracker,
ThreadedCalculationBodyCallback<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 ThreadedCalculationBodyCallback(Of TParameter)
)
public:
generic<typename TParameter>
where TParameter : ref class
static void For(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress^ tracker,
ThreadedCalculationBodyCallback<TParameter>^ body
)
static member For :
start : int *
stop : int *
parameter : 'TParameter *
tracker : ITrackCalculationProgress *
body : ThreadedCalculationBodyCallback<'TParameter> -> unit when 'TParameter : not struct
Parameters
- start
- Type: SystemInt32
The start of the loop. - stop
- Type: SystemInt32
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
, a copy of the parameter is made for each thread using
CopyForAnotherThread.
- tracker
- Type: AGI.FoundationITrackCalculationProgress
The object to which progress is reported and that is able to cancel this operation before it is complete, or . - body
- Type: AGI.Foundation.Infrastructure.ThreadingThreadedCalculationBodyCallbackTParameter
The body of the loop.
Type Parameters
- TParameter
- The type of an instance that is passed to the body of the loop.
See Also