ParallelEnumerable.AsUnordered<TSource>(ParallelQuery<TSource>) 方法

定义

允许将中间查询视为元素之间未应用任何排序。Allows an intermediate query to be treated as if no ordering is implied among the elements.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

输入序列。The input sequence.

返回

具有任意顺序的源序列。The source sequence with arbitrary order.

异常

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

注解

在查询的一部分不需要进行排序时,AsUnordered 可以提供性能优势。AsUnordered may provide performance benefits when ordering is not required in a portion of a query. 默认情况下,如果指定了 OrderBy 或 AsOrdered,PLINQ 会将输入序列视为未排序。By default, PLINQ treats an input sequence as unordered unless OrderBy or AsOrdered is specified. 但是,如果启用了排序并不再需要排序,则可以使用 AsUnordered 在查询中将其关闭,这可能会导致性能优势。AsUnordered 运算符本身不会打乱源序列的顺序;它只是删除后续操作员的排序要求。However, if ordering was turned on and is no longer needed, then AsUnordered can be used to turn it off in mid-query, and this may result in performance benefits.The AsUnordered operator itself does not shuffle the source sequence; it simply removes the ordering requirement for subsequent operators. 如果源是有序的,则后续的运算符可能会保留此顺序,因为这样做会更有效。If the source is ordered, subsequent operators might keep that ordering if it is more efficient to do so. AsUnordered 可在查询中的任何位置调用;不需要在 AsParallel 之后立即调用。AsUnordered can be called anywhere in the query; it does not need to be called immediately after AsParallel. 有关详细信息,请参阅了解 plinq 中的加速Plinq 中的顺序保留For more information, see Understanding Speedup in PLINQ and Order Preservation in PLINQ.

适用于

另请参阅