ThreadedCalculationForTParameter Method (Int32, Int32, TParameter, ITrackCalculationProgress, ThreadedCalculationBodyCallbackWithProgressTParameter) |
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.
The body of the
'for' loop is given an ITrackCalculationProgress instance that can be used to report
detailed information about the progress of individual loop iterations. It is not recommended to use
this overload when looping through a large number of iterations or when detailed information about
the progress of individual iterations is not required, because there is some overhead to the
detailed progress reporting.
Namespace:
AGI.Foundation.Infrastructure.Threading
Assembly:
AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 24.2.419.0 (24.2.419.0)
Syntax public static void For<TParameter>(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress tracker,
ThreadedCalculationBodyCallbackWithProgress<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 ThreadedCalculationBodyCallbackWithProgress(Of TParameter)
)
public:
generic<typename TParameter>
where TParameter : ref class
static void For(
int start,
int stop,
TParameter parameter,
ITrackCalculationProgress^ tracker,
ThreadedCalculationBodyCallbackWithProgress<TParameter>^ body
)
static member For :
start : int *
stop : int *
parameter : 'TParameter *
tracker : ITrackCalculationProgress *
body : ThreadedCalculationBodyCallbackWithProgress<'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.ThreadingThreadedCalculationBodyCallbackWithProgressTParameter
The body of the loop.
Type Parameters
- TParameter
- The type of an instance that is passed to the body of the loop.
See Also