KGySoft.Threading Namespace

The KGySoft.Threading namespace contains the static AsyncHelper class that makes possible to implement sync and async versions of a possibly parallel operation supporting cancellation and reporting progress using a single shared implementation. One built-in example is the ParallelHelper class, but you can find many examples in other dependent libraries such as the KGySoft.Drawing.Core package that uses many parallel operations for image processing. Apart from these you can find here the WaitHandleExtensions and some other types related to configuring or tracking asynchronous operations.
If you are looking for thread-safe collections such as the ThreadSafeDictionaryTKey, TValue, then see the KGySoft.Collections namespace instead.

Classes

AsyncConfig Represents asynchronous configuration for IAsyncResult-returning methods.
AsyncConfigBase Represents the base class for configuration of possibly asynchronous and multi-threaded operations.
See the Examples section of the AsyncHelper class for details.
AsyncContextWrapper Provides a wrapper of an existing IAsyncContext instance to override its MaxDegreeOfParallelism or to conceal its Progress.
See the Examples section of the AsyncHelper class for details about IAsyncContext.
AsyncHelper A helper class to implement CPU-bound operations with adjustable parallelization, cancellation and progress reporting, allowing a single shared implementation for both sync and async overloads where the latter can be either IAsyncResult or Task (.NET Framework 4.0 and later) returning methods.

See the online help for an example.
ParallelConfig Represents a configuration for parallel operations.
ParallelHelper 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.
SimpleContext Represents a predefined simple context for non-async, possibly parallel operations where the maximum degree of parallelism can be specified, but cancellation and reporting progress is not supported. Can be used for methods with an IAsyncContext parameter where we do not have an existing IAsyncContext instance from a higher level operation, and we want to force the degree of parallelism. To force a single threaded execution you can use the predefined AsyncHelper.SingleThreadContext property.
See the Examples section of the AsyncHelper class for details about IAsyncContext.
TaskConfig Represents asynchronous configuration for Task-returning methods.
WaitHandleExtensions Provides extension methods for the WaitHandle type.

Structures

AsyncProgressT Represents the progress of an operation that can be reported by an IAsyncProgress implementation.

Interfaces

IAsyncContext Represents the context of a possibly asynchronous operation.
See the Examples section of the AsyncHelper class to see how to create sync and async methods (supporting both Task and IAsyncResult return types) using the same shared implementation with an IAsyncContext parameter.
IAsyncProgress Represents a progress updates provider for asynchronous operations. It provides methods for updating the progress from concurrent threads.