Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
 ForAll(TSource) Method
Collapse All/Expand All Collapse All
.NET Framework Class Library
ParallelEnumerable..::.ForAll<(Of <(TSource>)>) Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Invokes in parallel the specified action for each element in the source.

Namespace:  System.Linq
Assembly:  System.Core (in System.Core.dll)
Visual Basic (Declaration)
<ExtensionAttribute> _
Public Shared Sub ForAll(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    action As Action(Of TSource) _
)
Visual Basic (Usage)
Dim source As ParallelQuery(Of TSource)
Dim action As Action(Of TSource)

source.ForAll(action)
C#
public static void ForAll<TSource>(
    this ParallelQuery<TSource> source,
    Action<TSource> action
)
Visual C++
[ExtensionAttribute]
public:
generic<typename TSource>
static void ForAll(
    ParallelQuery<TSource>^ source, 
    Action<TSource>^ action
)
F#
static member ForAll : 
        source:ParallelQuery<'TSource> * 
        action:Action<'TSource> -> unit 

Type Parameters

TSource

The type of elements of source.

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
The ParallelQuery<(Of <(TSource>)>) whose elements will be processed by action.
action
Type: System..::.Action<(Of <(TSource>)>)
An Action to invoke on each element.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ParallelQuery<(Of <(TSource>)>). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
ExceptionCondition
OperationCanceledException

The query was canceled.

ArgumentNullException

source or action is a null reference (Nothing in Visual Basic).

AggregateException

One or more exceptions occurred during the evaluation of the query.

This is an efficient way to process the output from a parallelized query because it does not require a merge step at the end. However, order of execution is non-deterministic.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker