AsyncContextSwitcherAwaitable struct¶
Attributes: [DebuggerDisplay("IsCompleted = {IsCompleted}, ForceYielding = {ForceYielding}")]
Defined in
Namespace: ReactiveUI.Primitives.Async.Reactive
Assembly: ReactiveUI.Primitives.Async.Reactive.dll
Full name: ReactiveUI.Primitives.Async.Reactive.AsyncContext.AsyncContextSwitcherAwaitable
Modifiers: public sealed
Summary¶
Provides an awaitable that switches execution to a specified asynchronous context, optionally forcing a yield
and supporting cancellation.
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 AsyncContextSwitcherAwaitable
class INotifyCompletion {
<>
}
INotifyCompletion <|.. AsyncContextSwitcherAwaitable
class IEquatable~AsyncContextSwitcherAwaitable~ {
<>
}
IEquatable~AsyncContextSwitcherAwaitable~ <|.. AsyncContextSwitcherAwaitable
Implements: INotifyCompletion, IEquatable
Remarks¶
Use this struct to ensure that code after an await resumes on a specific asynchronous context, such as a particular SynchronizationContext or TaskScheduler. If cancellation is requested before the continuation is scheduled, the continuation is invoked immediately and an OperationCanceledException will be thrown when GetResult is called. This type is intended for advanced scenarios where precise control over asynchronous context switching is required.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Provides an awaitable that switches execution to a specified asynchronous context, optionally forcing a yield and supporting cancellation. |
Properties¶
| Name | Summary |
|---|---|
| AsyncContext | The asynchronous context to which execution should be switched when awaited. |
| ForceYielding | true to always yield execution even if already in the target context; otherwise, false to avoid yielding if already in the specified context. |
| CancellationToken | A cancellation token that can be used to cancel the await operation before the continuation is scheduled. |
| IsCompleted | Gets a value indicating whether the asynchronous operation has completed in the current context. |
Methods¶
| Name | Summary |
|---|---|
| GetResult | Checks whether the associated cancellation token has had cancellation requested and throws an exception if so. |
| GetAwaiter | Returns an awaiter for this AsyncContextSwitcherAwaitable instance, enabling use of the await keyword to asynchronously switch execution context. |
| OnCompleted | Schedules the specified continuation action to be invoked when the operation has completed. |
| ToString | |
| GetHashCode | |
| Equals | |
| Deconstruct |
Operators¶
| Name | Summary |
|---|---|
| static op_Inequality | |
| static op_Equality |