Click or drag to resize

ThreadedCalculationForTParameter1, TParameter2 Method (Int32, Int32, TParameter1, TParameter2, ITrackCalculationProgress, ThreadedCalculationBodyCallbackWithProgress2TParameter1, 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.

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.1.418.0 (24.1.418.0)
Syntax
public static void For<TParameter1, TParameter2>(
	int start,
	int stop,
	TParameter1 parameter1,
	TParameter2 parameter2,
	ITrackCalculationProgress tracker,
	ThreadedCalculationBodyCallbackWithProgress2<TParameter1, TParameter2> body
)
where TParameter1 : class
where TParameter2 : class

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.ThreadingThreadedCalculationBodyCallbackWithProgress2TParameter1, 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