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¶
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¶
| Name | Summary |
|---|---|
| static Default | Gets the default instance of the AsyncContext class. |
| SynchronizationContext | Gets the synchronization context to use for marshaling callbacks and continuations. |
| TaskScheduler | Gets the task scheduler to use for scheduling tasks, or null to use the default scheduler. |
| Sequencer | Gets the sequencer used to schedule continuations, or null when another context shape is used. |
Methods¶
| Name | Summary |
|---|---|
| static From | Creates a new AsyncContext that uses the specified SynchronizationContext for asynchronous operations. |
| static GetCurrent | Gets the current asynchronous context associated with the calling thread. |
| SwitchContextAsync | Creates an awaitable that switches execution to the associated asynchronous context. |
| ToString | |
| GetHashCode | |
| Equals |
Operators¶
| Name | Summary |
|---|---|
| static op_Inequality | |
| static op_Equality |