Skip to content

AsyncContext record

Attributes: [DebuggerDisplay("SynchronizationContext = {SynchronizationContext}, TaskScheduler = {TaskScheduler}, Sequencer = {Sequencer}")]

Defined in

Namespace: ReactiveUI.Primitives.Async.Reactive Assembly: ReactiveUI.Primitives.Async.Reactive.dll Full name: ReactiveUI.Primitives.Async.Reactive.AsyncContext Modifiers: public sealed

Summary

View source

        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 a SynchronizationContext, TaskScheduler, or ISequencer. The Default context represents the absence of a specific synchronization or scheduling context, and typically corresponds to the default task scheduler.

Properties

NameSummary
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.
SequencerGets the sequencer used to schedule continuations, or null when another context shape is used.

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
GetHashCode
Equals

Operators

NameSummary
static op_Inequality
static op_Equality
Inherited members

Extension members