ParallelEnumerable.WithExecutionMode<TSource> Method (ParallelQuery<TSource>, ParallelExecutionMode)

.NET Framework (current version)

Sets the execution mode of the query.

Namespace:   System.Linq
Assembly:  System.Core (in System.Core.dll)

public static ParallelQuery<TSource> WithExecutionMode<TSource>(
	this ParallelQuery<TSource> source,
	ParallelExecutionMode executionMode


Type: System.Linq.ParallelQuery<TSource>

A ParallelQuery on which to set the option.

Type: System.Linq.ParallelExecutionMode

The mode in which to execute the query.

Return Value

Type: System.Linq.ParallelQuery<TSource>

ParallelQuery representing the same query as source, but with the registered execution mode.

Type Parameters


The type of elements of source.

Exception Condition

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


executionMode is not a valid ParallelExecutionMode value.


WithExecutionMode is used multiple times in the query.

The execution mode specifies whether PLINQ will attempt to fall back to sequential execution if it detects certain query shapes. For more information and examples, see How to: Specify the Execution Mode in PLINQ.

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
Return to top