SynchronizationContextExtensions.SynchronizationContextAwaiter Struct
Awaits a SynchronizationContext, resuming the awaiting method on that context.
public readonly struct SynchronizationContextAwaiter : ICriticalNotifyCompletion, INotifyCompletionConstructors
| Name | Description |
|---|---|
| SynchronizationContextAwaiter(SynchronizationContext) | Awaits a SynchronizationContext, resuming the awaiting method on that context. |
SynchronizationContextAwaiter(SynchronizationContext)
Awaits a SynchronizationContext, resuming the awaiting method on that context.
public SynchronizationContextAwaiter(SynchronizationContext synchronizationContext)Parameters
synchronizationContextSynchronizationContext- The synchronization context to resume on.
Properties
| Name | Description |
|---|---|
| IsCompleted | Gets a value indicating whether the current synchronization context is the awaited one, in which case the awaiting method continues synchronously. |
IsCompleted
SynchronizationContextExtensions.csGets a value indicating whether the current synchronization context is the awaited one, in which case the awaiting method continues synchronously.
public bool IsCompleted { get; }Property value
Remarks
The synchronization contexts are compared by instance. A different instance bound to the same thread, such as the ones WPF installs while running a dispatcher operation, is not recognized: the continuation is then posted, which is still correct but does not complete synchronously.
Methods
| Name | Description |
|---|---|
| GetResult() | Ends the await. This method does nothing. |
| OnCompleted(Action) | Posts continuation to the synchronization context. |
| UnsafeOnCompleted(Action) | Posts continuation to the synchronization context. |
GetResult()
SynchronizationContextExtensions.csEnds the await. This method does nothing.
public void GetResult()OnCompleted(Action)
SynchronizationContextExtensions.csUnsafeOnCompleted(Action)
SynchronizationContextExtensions.csPosts continuation to the synchronization context.
Parameters
continuationAction- The action to invoke once the awaiting method resumes.
Remarks
The async method builders call this method and flow the ExecutionContext themselves.