-
-
Notifications
You must be signed in to change notification settings - Fork 357
Home
AsyncEx is a library designed to assist with programming when using the async
and await
keywords.
Most people just need AsyncLock, but AsyncEx also includes AsyncManualResetEvent, AsyncAutoResetEvent, AsyncConditionVariable, AsyncMonitor, AsyncSemaphore, AsyncCountdownEvent, AsyncBarrier, and AsyncReaderWriterLock.
AsyncProducerConsumerQueue is an async
-ready producer/consumer queue that works on all platforms.
AsyncCollection is an async
-compatible wrapper around IProducerConsumerCollection
, in the same way that BlockingCollection is a blocking wrapper around IProducerConsumerCollection
.
You can also use ProducerProgress to send IProgress
updates to a producer/consumer collection.
The AsyncLazy class provides support for asynchronous lazy initialization.
The AsyncContext class and the related AsyncContextThread
class provide contexts for asynchronous operations for situations where such a context is lacking (i.e., Console applications and Win32 services).
DeferralManager simplifies the writing of "command-style" events that provide a GetDeferral
method.
NotifyTaskCompletion is a data-binding-friendly wrapper for Task
, providing property-change notifications when the task completes.
The AsyncFactory classes interoperate between Task-based Asynchronous Programming (async
) and the Asynchronous Programming Model (IAsyncResult
). AsyncFactory<T>
can also create wrapper tasks for most events.
TaskCompletionSource is a non-generic version of the built-in TaskCompletionSource<TResult>
.
TaskCompletionSourceExtensions includes TryCompleteFromEventArgs
, which helps interoperate between Task-based Asynchronous Programming (async
) and Event-based Asynchronous Programming (*Completed
).
You can use OrderByCompletion to order tasks by when they complete.
CancellationTokenHelpers provides some static methods and constants for working with CancellationToken
s.
TaskConstants provides static constant Task<TResult>
values that are useful when taking advantage of the async fast path.
You can respond to task progress updates by using one of the implementations of IProgress<T>
: PropertyProgress, ProducerProgress, or DataflowProgress.
ObservableProgress
, an IProgress<T>
implementation that exposes progress updates as an IObservable<T>
stream, is available as a gist.
CancellationToken.AsTask will create a task that is canceled when a CancellationToken
is canceled.
TaskCompletionSourceExtensions has several extension methods for TaskCompletionSource
, including propagating results from a completed Task
or AsyncCompletedEventArgs
, and for completing the source forcing background continuations.
TaskFactoryExtensions adds Run
overloads to task factories.
There is currently only one Dataflow block in the library: FuncBlock, which allows an async
function to provide data to a dataflow mesh with full cooperative cancellation and error propagation.
ExceptionHelpers.PrepareForRethrow will preserve the stack trace when rethrowing any exception.
For dealing with SynchronizationContext
directly, the library provides CurrentOrDefault and SynchronizationContextSwitcher.