ParallelHelperBeginSortTKey, TValue(ArraySectionTKey, ArraySectionTValue, IComparerTKey, AsyncConfig) Method

Sorts the elements in a pair of ArraySectionT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
public static IAsyncResult BeginSort<TKey, TValue>(
	ArraySection<TKey> keys,
	ArraySection<TValue> values,
	IComparer<TKey>? comparer = null,
	AsyncConfig? asyncConfig = null
)

Parameters

keys  ArraySectionTKey
The ArraySectionT that contains the keys to sort.
values  ArraySectionTValue
The ArraySectionT that contains the values that correspond to the keys in the keys collection. If the IsNull property of values is , then only the keys are sorted.
comparer  IComparerTKey  (Optional)
The IComparerT implementation to use when comparing elements, or to use a default comparer. This parameter is optional.
Default value: .
asyncConfig  AsyncConfig  (Optional)
An optional configuration to adjust parallelization or cancellation. Reporting progress is not supported in sorting methods. This parameter is optional.
Default value: .

Type Parameters

TKey
The type of the elements in the keys collection.
TValue
The type of the elements in the values collection.

Return Value

IAsyncResult
An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

In .NET Framework 4.0 and above you can use also the SortAsync methods.

To get the result or the exception that occurred during the operation you have to call the EndSort method.

This method is not a blocking call even if the MaxDegreeOfParallelism property of the asyncConfig parameter is 1.

Exceptions

ArgumentExceptionThe IsNull property of values is and values has fewer elements than keys.

See Also