AsyncContextSwitcherAwaitable(AsyncContext, bool, CancellationToken) constructor¶
Defined in
Type: AsyncContextSwitcherAwaitable
Namespace: ReactiveUI.Primitives.Async.Reactive
Assembly: ReactiveUI.Primitives.Async.Reactive.dll
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
public AsyncContextSwitcherAwaitable(AsyncContext AsyncContext, bool ForceYielding, CancellationToken CancellationToken)
Summary: Provides an awaitable that switches execution to a specified asynchronous context, optionally forcing a yield and supporting cancellation.
Parameters
| Name | Type | Description |
|---|---|---|
AsyncContext | [AsyncContext](# | The asynchronous context to which execution should be switched when awaited. |
ForceYielding | bool | true to always yield execution even if already in the target context; otherwise, false to avoid yielding if already in the specified context. |
CancellationToken | CancellationToken | A cancellation token that can be used to cancel the await operation before the continuation is scheduled. |
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.