ParallelHelper Class

The ParallelHelper class contains similar methods to the Parallel.For overloads in .NET Framework 4.0 and later but the ones in this class can be used even on .NET Framework 3.5, support reporting progress and have async overloads. Furthermore, it also contains several sorting methods that can sort IListT instances in place using multiple threads.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static class ParallelHelper
Inheritance
Object    ParallelHelper

Properties

CoreCount Gets the number of processor cores available for the current process.

Methods

BeginFor(Int32, Int32, ActionInt32) Begins to execute an indexed loop asynchronously, in which iterations may run in parallel.
BeginFor(Int32, Int32, AsyncConfig, ActionInt32) Begins to execute an indexed loop asynchronously, in which iterations may run in parallel and the execution can be configured.
See the Remarks section of the BeginForT(T, Int32, Int32, AsyncConfig, ActionInt32) overload for details.
BeginForT(T, Int32, Int32, AsyncConfig, ActionInt32) Begins to execute an indexed loop asynchronously, in which iterations may run in parallel and the execution can be configured.
BeginSortT(ArraySectionT, IComparerT, AsyncConfig) Sorts the elements of the specified ArraySectionT asynchronously, potentially using multiple threads.
BeginSortT(IListT, IComparerT, AsyncConfig) Sorts the elements of the specified list asynchronously, potentially using multiple threads.
BeginSortT(IListT, Int32, Int32, IComparerT, AsyncConfig) Sorts the elements of the specified list asynchronously, potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
BeginSortTFrom, TTo(CastArrayTFrom, TTo, IComparerTTo, AsyncConfig) Sorts the elements of the specified CastArrayTFrom, TTo asynchronously, potentially using multiple threads.
BeginSortTKey, TValue(ArraySectionTKey, ArraySectionTValue, IComparerTKey, AsyncConfig) Sorts the elements in a pair of ArraySectionT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
BeginSortTKey, TValue(IListTKey, IListTValue, IComparerTKey, AsyncConfig) Sorts the elements in a pair of IListT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
BeginSortTKey, TValue(IListTKey, IListTValue, Int32, Int32, IComparerTKey, AsyncConfig) Sorts the elements in a pair of IListT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
BeginSortTKeyFrom, TKeyTo, TValueFrom, TValueTo(CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo, AsyncConfig) Sorts the elements in a pair of CastArrayTFrom, TTo instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
EndFor Waits for the pending asynchronous operation started by one of the BeginFor methods to complete. In .NET Framework 4.0 and above you can use the ForAsync methods instead.
EndSort Waits for the pending asynchronous operation started by one of the BeginSort methods to complete. In .NET Framework 4.0 and above you can use the SortAsync methods instead.
For(Int32, Int32, ActionInt32) Executes an indexed loop synchronously, in which iterations may run in parallel.
For(Int32, Int32, ParallelConfig, ActionInt32) Executes an indexed loop synchronously, in which iterations may run in parallel and the execution can be configured.
See the Remarks section of the ForT(T, Int32, Int32, ParallelConfig, ActionInt32) overload for details.
ForT(IAsyncContext, T, Int32, Int32, ActionInt32) Executes an indexed loop using a context that may belong to a higher level, possibly asynchronous operation.
ForT(T, Int32, Int32, ParallelConfig, ActionInt32) Executes an indexed loop synchronously, in which iterations may run in parallel and the execution can be configured.
ForAsync(Int32, Int32, ActionInt32) Executes an indexed loop asynchronously, in which iterations may run in parallel.
ForAsync(Int32, Int32, TaskConfig, ActionInt32) Executes an indexed loop asynchronously, in which iterations may run in parallel and the execution can be configured.
See the Remarks section of the ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) overload for details.
ForAsyncT(T, Int32, Int32, TaskConfig, ActionInt32) Executes an indexed loop asynchronously, in which iterations may run in parallel and the execution can be configured.
SortT(ArraySectionT, IComparerT) Sorts the elements of the specified ArraySectionT synchronously, potentially using multiple threads.
SortT(IListT, IComparerT) Sorts the elements of the specified list synchronously, potentially using multiple threads.
SortT(ArraySectionT, IComparerT, ParallelConfig) Sorts the elements of the specified ArraySectionT synchronously, potentially using multiple threads.
SortT(IAsyncContext, ArraySectionT, IComparerT) Sorts the elements of the specified ArraySectionT synchronously, potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortT(IAsyncContext, IListT, IComparerT) Sorts the elements of the specified list synchronously, potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortT(IListT, IComparerT, ParallelConfig) Sorts the elements of the specified list synchronously, potentially using multiple threads.
SortT(IListT, Int32, Int32, IComparerT) Sorts the elements of the specified list synchronously, potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortT(IAsyncContext, IListT, Int32, Int32, IComparerT) Sorts the elements of the specified list synchronously, potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation. The range of elements to sort is specified by a starting index and a length.
SortT(IListT, Int32, Int32, IComparerT, ParallelConfig) Sorts the elements of the specified list synchronously, potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortTFrom, TTo(CastArrayTFrom, TTo, IComparerTTo) Sorts the elements of the specified CastArrayTFrom, TTo synchronously, potentially using multiple threads.
SortTKey, TValue(ArraySectionTKey, ArraySectionTValue, IComparerTKey) Sorts the elements in a pair of ArraySectionT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTFrom, TTo(CastArrayTFrom, TTo, IComparerTTo, ParallelConfig) Sorts the elements of the specified CastArrayTFrom, TTo synchronously, potentially using multiple threads.
SortTFrom, TTo(IAsyncContext, CastArrayTFrom, TTo, IComparerTTo) Sorts the elements of the specified CastArrayTFrom, TTo synchronously, potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortTKey, TValue(IListTKey, IListTValue, IComparerTKey) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTKey, TValue(ArraySectionTKey, ArraySectionTValue, IComparerTKey, ParallelConfig) Sorts the elements in a pair of ArraySectionT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTKey, TValue(IAsyncContext, ArraySectionTKey, ArraySectionTValue, IComparerTKey) Sorts the elements in a pair of ArraySectionT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortTKey, TValue(IAsyncContext, IListTKey, IListTValue, IComparerTKey) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortTKey, TValue(IListTKey, IListTValue, IComparerTKey, ParallelConfig) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTKey, TValue(IListTKey, IListTValue, Int32, Int32, IComparerTKey) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortTKey, TValue(IAsyncContext, IListTKey, IListTValue, Int32, Int32, IComparerTKey) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation. The range of elements to sort is specified by a starting index and a length.
SortTKey, TValue(IListTKey, IListTValue, Int32, Int32, IComparerTKey, ParallelConfig) Sorts the elements in a pair of IListT instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortTKeyFrom, TKeyTo, TValueFrom, TValueTo(CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo) Sorts the elements in a pair of CastArrayTFrom, TTo instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTKeyFrom, TKeyTo, TValueFrom, TValueTo(CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo, ParallelConfig) Sorts the elements in a pair of CastArrayTFrom, TTo instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortTKeyFrom, TKeyTo, TValueFrom, TValueTo(IAsyncContext, CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo) Sorts the elements in a pair of CastArrayTFrom, TTo instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads, using a context that may belong to a higher level, possibly asynchronous operation.
SortAsyncT(ArraySectionT, IComparerT, TaskConfig) Sorts the elements of the specified ArraySectionT asynchronously, potentially using multiple threads.
SortAsyncT(IListT, IComparerT, TaskConfig) Sorts the elements of the specified list asynchronously, potentially using multiple threads.
SortAsyncT(IListT, Int32, Int32, IComparerT, TaskConfig) Sorts the elements of the specified list asynchronously, potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortAsyncTFrom, TTo(CastArrayTFrom, TTo, IComparerTTo, TaskConfig) Sorts the elements of the specified CastArrayTFrom, TTo asynchronously, potentially using multiple threads.
SortAsyncTKey, TValue(ArraySectionTKey, ArraySectionTValue, IComparerTKey, TaskConfig) Sorts the elements in a pair of ArraySectionT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortAsyncTKey, TValue(IListTKey, IListTValue, IComparerTKey, TaskConfig) Sorts the elements in a pair of IListT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
SortAsyncTKey, TValue(IListTKey, IListTValue, Int32, Int32, IComparerTKey, TaskConfig) Sorts the elements in a pair of IListT instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads. The range of elements to sort is specified by a starting index and a length.
SortAsyncTKeyFrom, TKeyTo, TValueFrom, TValueTo(CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo, TaskConfig) Sorts the elements in a pair of CastArrayTFrom, TTo instances asynchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.

See Also