ParallelEnumerable.AsOrdered Method

Definition

Overloads

AsOrdered(ParallelQuery)

Enables treatment of a data source as if it were ordered, overriding the default of unordered. AsOrdered may only be invoked on non-generic sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

AsOrdered<TSource>(ParallelQuery<TSource>)

Enables treatment of a data source as if it were ordered, overriding the default of unordered. AsOrdered may only be invoked on generic sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

AsOrdered(ParallelQuery)

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

Enables treatment of a data source as if it were ordered, overriding the default of unordered. AsOrdered may only be invoked on non-generic sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

C#
public static System.Linq.ParallelQuery AsOrdered(this System.Linq.ParallelQuery source);

Parameters

source
ParallelQuery

The input sequence.

Returns

The source sequence which will maintain the original ordering in the subsequent query operators.

Exceptions

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

thrown if source contains no elements

-or-

if AsOrdered is called midway through a query. It is allowed to be called immediately after AsParallel(IEnumerable), Range(Int32, Int32), or Repeat<TResult>(TResult, Int32).

-or-

source is not one of AsParallel(IEnumerable), Range(Int32, Int32), or Repeat<TResult>(TResult, Int32).

Remarks

A natural tension exists between performance and preserving order in parallel processing. By default, a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered is applied or there is an explicit OrderBy operator in the query. For more information, see Order Preservation in PLINQ.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

AsOrdered<TSource>(ParallelQuery<TSource>)

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

Enables treatment of a data source as if it were ordered, overriding the default of unordered. AsOrdered may only be invoked on generic sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

C#
public static System.Linq.ParallelQuery<TSource> AsOrdered<TSource>(this System.Linq.ParallelQuery<TSource> source);

Type Parameters

TSource

The type of elements of source.

Parameters

source
ParallelQuery<TSource>

The input sequence.

Returns

The source sequence which will maintain the original ordering in the subsequent query operators.

Exceptions

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

source contains no elements

-or-

source is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat.

Remarks

A natural tension exists between performance and preserving order in parallel processing. By default, a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered is applied or there is an explicit OrderBy operator in the query. For more information, see Order Preservation in PLINQ.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0