DispatcherExtensions.SwitchToUiAwaitable Struct
An awaitable that switches execution to the UI thread.
public readonly struct SwitchToUiAwaitable : INotifyCompletionRemarks
Instances must be obtained from DispatcherExtensions.SwitchToDispatcherThread. A default-initialized value has no dispatcher to switch to and throws InvalidOperationException when awaited.
- Implements
Properties
| Name | Description |
|---|---|
| IsCompleted | Gets a value indicating whether the awaiter has completed. |
IsCompleted
DispatcherExtensions.csGets a value indicating whether the awaiter has completed.
public bool IsCompleted { get; }Property value
Exceptions
InvalidOperationException- The instance was default-initialized instead of being obtained from
DispatcherExtensions.SwitchToDispatcherThread.
Methods
| Name | Description |
|---|---|
| GetAwaiter() | Gets the awaiter for this awaitable. |
| GetResult() | Ends the await operation. |
| OnCompleted(Action) | Schedules the continuation action to run on the dispatcher thread. |
GetAwaiter()
DispatcherExtensions.csGets the awaiter for this awaitable.
public DispatcherExtensions.SwitchToUiAwaitable GetAwaiter()Returns
DispatcherExtensions.SwitchToUiAwaitable This instance.
GetResult()
DispatcherExtensions.csEnds the await operation.
public void GetResult()OnCompleted(Action)
DispatcherExtensions.csSchedules the continuation action to run on the dispatcher thread.
Parameters
continuationAction- The continuation action.
Exceptions
InvalidOperationException- The instance was default-initialized instead of being obtained from
DispatcherExtensions.SwitchToDispatcherThread, or the dispatcher has already shut down.