Skip to content

AsyncContext record

Defined in

Namespace: ReactiveUI.Extensions.Async Assembly: ReactiveUI.Extensions.dll Full name: ReactiveUI.Extensions.Async.AsyncContext Modifiers: public

Summary

        Represents an asynchronous execution context that encapsulates a specific SynchronizationContext or TaskScheduler
        for controlling the scheduling of asynchronous operations.
        

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Class hierarchy
classDiagram
class AsyncContext
class IEquatable~AsyncContext~ {
    <>
}
IEquatable~AsyncContext~ <|.. AsyncContext

Implements: IEquatable

Remarks

Use AsyncContext to capture and restore a particular synchronization or task scheduling environment when running asynchronous code. This is useful for ensuring that continuations or asynchronous callbacks execute on a desired context, such as a UI thread or a custom scheduler. An AsyncContext can be created from either a SynchronizationContext or a TaskScheduler, but not both at the same time. The Default context represents the absence of a specific synchronization or scheduling context, and typically corresponds to the default task scheduler.

Constructors

NameSummary
.ctor

Properties

NameSummary
EqualityContract
static DefaultGets the default instance of the AsyncContext class.
SynchronizationContextGets the synchronization context to use for marshaling callbacks and continuations.
TaskSchedulerGets the task scheduler to use for scheduling tasks, or null to use the default scheduler.

Methods

NameSummary
static FromCreates a new AsyncContext that uses the specified SynchronizationContext for asynchronous operations.
static GetCurrentGets the current asynchronous context associated with the calling thread.
SwitchContextAsyncCreates an awaitable that switches execution to the associated asynchronous context.
ToString
PrintMembers
GetHashCode
Equals

Operators

NameSummary
static op_Inequality
static op_Equality
Inherited members

Extension members