Click or drag to resize
DigitalRuneParallelForEachT Method
Executes a for-each loop where each iteration can potentially occur in parallel with others.

Namespace: DigitalRune.Threading
Assembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax
public static void ForEach<T>(
	IEnumerable<T> collection,
	Action<T> action
)

Parameters

collection
Type: System.Collections.GenericIEnumerableT
The enumerable data source.
action
Type: SystemActionT
The method to execute at each iteration. The item to process is supplied as the parameter.

Type Parameters

T
The type of item to iterate over.
Exceptions
ExceptionCondition
ArgumentNullException Either collection or action is .
Remarks
The parallel foreach-loop has a few disadvantages: Enumerating the sequence in parallel requires locking. In addition, creating an IEnumeratorT object allocates memory on the managed heap. It is therefore recommended to use the parallel for-loop instead of the parallel for-each loop where possible.
See Also