ParallelEnumerable.WithExecutionMode<TSource>(ParallelQuery<TSource>, ParallelExecutionMode) 方法

定义

设置查询的执行模式。Sets the execution mode of the query.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ WithExecutionMode(System::Linq::ParallelQuery<TSource> ^ source, System::Linq::ParallelExecutionMode executionMode);
public static System.Linq.ParallelQuery<TSource> WithExecutionMode<TSource> (this System.Linq.ParallelQuery<TSource> source, System.Linq.ParallelExecutionMode executionMode);
static member WithExecutionMode : System.Linq.ParallelQuery<'Source> * System.Linq.ParallelExecutionMode -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function WithExecutionMode(Of TSource) (source As ParallelQuery(Of TSource), executionMode As ParallelExecutionMode) As ParallelQuery(Of TSource)

类型参数

TSource

source 的元素类型。The type of elements of source.

参数

source
ParallelQuery<TSource>

要对其设置选项的 ParallelQuery。A ParallelQuery on which to set the option.

executionMode
ParallelExecutionMode

执行查询使用的模式。The mode in which to execute the query.

返回

表示与源相同的查询的 ParallelQuery,但带有已注册的执行模式。ParallelQuery representing the same query as source, but with the registered execution mode.

异常

source 为 null 引用(在 Visual Basic 中为 Nothing)。source is a null reference (Nothing in Visual Basic).

executionMode 不是有效的 ParallelExecutionMode 值。executionMode is not a valid ParallelExecutionMode value.

WithExecutionMode 在查询中多次使用。WithExecutionMode is used multiple times in the query.

注解

执行模式指定如果 PLINQ 检测到特定的查询形状,PLINQ 是否会尝试回退到顺序执行。The execution mode specifies whether PLINQ will attempt to fall back to sequential execution if it detects certain query shapes. 有关详细信息和示例,请参阅如何:在 PLINQ 中指定执行模式For more information and examples, see How to: Specify the Execution Mode in PLINQ.

适用于

另请参阅