ParallelEnumerable.WithDegreeOfParallelism<TSource>(ParallelQuery<TSource>, Int32) 方法

定义

设置要在查询中使用的并行度。Sets the degree of parallelism to use in a query. 并行度是将用于处理查询的同时执行的任务的最大数目。Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

要对其设置并行度限制的 ParallelQuery。A ParallelQuery on which to set the limit on the degrees of parallelism.

degreeOfParallelism
Int32

查询的并行度。The degree of parallelism for the query.

返回

表示与源相同的查询的 ParallelQuery,其中设置了对并行度的限制。ParallelQuery representing the same query as source, with the limit on the degrees of parallelism set.

异常

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

degreeOfParallelism 小于 1 或大于 512。degreeOfParallelism is less than 1 or greater than 512.

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

适用于

另请参阅