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 (which is basically a target framework independent advanced version of Parallel.For) 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.


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.
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.
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.
TaskConfig Represents asynchronous configuration for Task-returning methods.
WaitHandleExtensions Provides extension methods for the WaitHandle type.


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


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.