ParallelHelperSortAsyncT(ArraySectionT, IComparerT, TaskConfig) Method

Sorts the elements of the specified ArraySectionT asynchronously, potentially using multiple threads.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
public static Task<bool> SortAsync<T>(
	ArraySection<T> array,
	IComparer<T>? comparer = null,
	TaskConfig? asyncConfig = null
)

Parameters

array  ArraySectionT
The ArraySectionT instance to sort.
comparer  IComparerT  (Optional)
The IComparerT implementation to use when comparing elements, or to use a default comparer. This parameter is optional.
Default value: .
asyncConfig  TaskConfig  (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

T
The type of the elements in the ArraySectionT.

Return Value

TaskBoolean
A task that represents the asynchronous operation. Its result is , if the operation completed successfully, or , if the operation has been canceled and ThrowIfCanceled in asyncConfig parameter was .

Remarks

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

Exceptions

ArgumentExceptionThe comparer returned inconsistent results.
InvalidOperationExceptioncomparer is , and an element does not implement the IComparableT interface.
TaskCanceledExceptionThe operation has been canceled and ThrowIfCanceled in asyncConfig was . This exception is thrown when the result is awaited.

See Also