ThreadedCalculationForTParameter1, TParameter2 Method (Int32, Int32, TParameter1, TParameter2, ITrackCalculationProgress, ThreadedCalculationBodyCallback2TParameter1, TParameter2) |
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.2.419.0 (24.2.419.0)
Syntax public static void For<TParameter1, TParameter2>(
int start,
int stop,
TParameter1 parameter1,
TParameter2 parameter2,
ITrackCalculationProgress tracker,
ThreadedCalculationBodyCallback2<TParameter1, TParameter2> body
)
where TParameter1 : class
where TParameter2 : class
Public Shared Sub For(Of TParameter1 As Class, TParameter2 As Class) (
start As Integer,
stop As Integer,
parameter1 As TParameter1,
parameter2 As TParameter2,
tracker As ITrackCalculationProgress,
body As ThreadedCalculationBodyCallback2(Of TParameter1, TParameter2)
)
public:
generic<typename TParameter1, typename TParameter2>
where TParameter1 : ref class
where TParameter2 : ref class
static void For(
int start,
int stop,
TParameter1 parameter1,
TParameter2 parameter2,
ITrackCalculationProgress^ tracker,
ThreadedCalculationBodyCallback2<TParameter1, TParameter2>^ body
)
static member For :
start : int *
stop : int *
parameter1 : 'TParameter1 *
parameter2 : 'TParameter2 *
tracker : ITrackCalculationProgress *
body : ThreadedCalculationBodyCallback2<'TParameter1, 'TParameter2> -> unit when 'TParameter1 : not struct when 'TParameter2 : 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.
- parameter1
- Type: TParameter1
The first 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.
- parameter2
- Type: TParameter2
The second 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.ThreadingThreadedCalculationBodyCallback2TParameter1, TParameter2
The body of the loop.
Type Parameters
- TParameter1
- The type of the first parameter that is passed to the body of the loop.
- TParameter2
- The type of the second parameter that is passed to the body of the loop.
See Also