Parallel Class

.NET Framework (current version)
 

Provides support for parallel loops and regions.

Namespace:   System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

System.Object
  System.Threading.Tasks.Parallel

<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,
	ExternalThreading := True)>
Public NotInheritable Class Parallel

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticFor(Int32, Int32, Action(Of Int32, ParallelLoopState))

Executes a for (For in Visual Basic) loop in which iterations may run in parallel and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int32, Int32, Action(Of Int32))

Executes a for (For in Visual Basic) loop in which iterations may run in parallel.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int32, Int32, ParallelOptions, Action(Of Int32, ParallelLoopState))

Executes a for (For in Visual Basic) loop in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int32, Int32, ParallelOptions, Action(Of Int32))

Executes a for (For in Visual Basic) loop in which iterations may run in parallel and loop options can be configured.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int64, Int64, Action(Of Int64, ParallelLoopState))

Executes a for (For in Visual Basic) loop with 64-bit indexes in which iterations may run in parallel and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int64, Int64, Action(Of Int64))

Executes a for (For in Visual Basic) loop with 64-bit indexes in which iterations may run in parallel.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int64, Int64, ParallelOptions, Action(Of Int64, ParallelLoopState))

Executes a for (For in Visual Basic) loop with 64-bit indexes in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Int64, Int64, ParallelOptions, Action(Of Int64))

Executes a for (For in Visual Basic) loop with 64-bit indexes in which iterations may run in parallel and loop options can be configured.

System_CAPS_pubmethodSystem_CAPS_staticFor(Of TLocal)(Int32, Int32, Func(Of TLocal), Func(Of Int32, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a for (For in Visual Basic) loop with thread-local data in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Of TLocal)(Int32, Int32, ParallelOptions, Func(Of TLocal), Func(Of Int32, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a for (For in Visual Basic) loop with thread-local data in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Of TLocal)(Int64, Int64, Func(Of TLocal), Func(Of Int64, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a for (For in Visual Basic) loop with 64-bit indexes and thread-local data in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticFor(Of TLocal)(Int64, Int64, ParallelOptions, Func(Of TLocal), Func(Of Int64, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a for (For in Visual Basic) loop with 64-bit indexes and thread-local data in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), Action(Of TSource, ParallelLoopState, Int64))

Executes a foreach (For Each in Visual Basic) operation with 64-bit indexes on an IEnumerable in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), Action(Of TSource, ParallelLoopState))

Executes a foreach (For Each in Visual Basic) operation on an IEnumerable in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), Action(Of TSource))

Executes a foreach (For Each in Visual Basic) operation on an IEnumerable in which iterations may run in parallel.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), ParallelOptions, Action(Of TSource, ParallelLoopState, Int64))

Executes a foreach (For Each in Visual Basic) operation with 64-bit indexes on an IEnumerable in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), ParallelOptions, Action(Of TSource, ParallelLoopState))

Executes a foreach (For Each in Visual Basic) operation on an IEnumerable in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(IEnumerable(Of TSource), ParallelOptions, Action(Of TSource))

Executes a foreach (For Each in Visual Basic) operation on an IEnumerable in which iterations may run in parallel and loop options can be configured.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(OrderablePartitioner(Of TSource), Action(Of TSource, ParallelLoopState, Int64))

Executes a foreach (For Each in Visual Basic) operation on a OrderablePartitioner(Of TSource) in which iterations may run in parallel and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(OrderablePartitioner(Of TSource), ParallelOptions, Action(Of TSource, ParallelLoopState, Int64))

Executes a foreach (For Each in Visual Basic) operation on a OrderablePartitioner(Of TSource) in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(Partitioner(Of TSource), Action(Of TSource, ParallelLoopState))

Executes a foreach (For Each in Visual Basic) operation on a System.Collections.Concurrent.Partitioner in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(Partitioner(Of TSource), Action(Of TSource))

Executes a foreach (For Each in Visual Basic) operation on a Partitioner in which iterations may run in parallel.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(Partitioner(Of TSource), ParallelOptions, Action(Of TSource, ParallelLoopState))

Executes a foreach (For Each in Visual Basic) operation on a Partitioner in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource)(Partitioner(Of TSource), ParallelOptions, Action(Of TSource))

Executes a foreach (For Each in Visual Basic) operation on a Partitioner in which iterations may run in parallel and loop options can be configured.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(IEnumerable(Of TSource), Func(Of TLocal), Func(Of TSource, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(IEnumerable(Of TSource), Func(Of TLocal), Func(Of TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable in which iterations may run in parallel and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(IEnumerable(Of TSource), ParallelOptions, Func(Of TLocal), Func(Of TSource, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on an IEnumerable in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated..

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(IEnumerable(Of TSource), ParallelOptions, Func(Of TLocal), Func(Of TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data and 64-bit indexes on an IEnumerable in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(OrderablePartitioner(Of TSource), Func(Of TLocal), Func(Of TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on a OrderablePartitioner(Of TSource) in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(OrderablePartitioner(Of TSource), ParallelOptions, Func(Of TLocal), Func(Of TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with 64-bit indexes and with thread-local data on a OrderablePartitioner(Of TSource) in which iterations may run in parallel , loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(Partitioner(Of TSource), Func(Of TLocal), Func(Of TSource, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on a Partitioner in which iterations may run in parallel and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticForEach(Of TSource, TLocal)(Partitioner(Of TSource), ParallelOptions, Func(Of TLocal), Func(Of TSource, ParallelLoopState, TLocal, TLocal), Action(Of TLocal))

Executes a foreach (For Each in Visual Basic) operation with thread-local data on a Partitioner in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

System_CAPS_pubmethodSystem_CAPS_staticInvoke(Action())

Executes each of the provided actions, possibly in parallel.

System_CAPS_pubmethodSystem_CAPS_staticInvoke(ParallelOptions, Action())

Executes each of the provided actions, possibly in parallel, unless the operation is cancelled by the user.

The Parallel class provides library-based data parallel replacements for common operations such as for loops, for each loops, and execution of a set of statements.

This example demonstrates several approaches to implementing a parallel loop using multiple language constructs.

Imports System.Threading.Tasks
Module Module1

    Sub Main()
        Dim N As Integer = 1000

        ' Using a named method
        Parallel.For(0, N, AddressOf Method2)

        ' Using a lambda expression.
        Parallel.For(0, N, Sub(i)
                               ' Do Work
                           End Sub)
    End Sub

    Sub Method2(ByVal i As Integer)
        ' Do work.
    End Sub

End Module

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1

All public and protected members of Parallel are thread-safe and may be used concurrently from multiple threads.

Return to top
Show: