SynchronizationContextExtensions Class

Provides extension methods for SynchronizationContext.

public static class SynchronizationContextExtensions

Nested types

NameDescription
SynchronizationContextExtensions.SynchronizationContextAwaiterAwaits a SynchronizationContext, resuming the awaiting method on that context.

Methods

NameDescription
GetAwaiter(SynchronizationContext)Gets an awaiter that will post the continuation to the specified synchronization context.

GetAwaiter(SynchronizationContext)

SynchronizationContextExtensions.cs

Gets an awaiter that will post the continuation to the specified synchronization context.

public static SynchronizationContextExtensions.SynchronizationContextAwaiter GetAwaiter(this SynchronizationContext synchronizationContext)

Parameters

synchronizationContext SynchronizationContext
The synchronization context to post the continuation to.

Returns

SynchronizationContextExtensions.SynchronizationContextAwaiter A SynchronizationContextExtensions.SynchronizationContextAwaiter instance.

Remarks

The continuation is posted to the synchronization context. When SynchronizationContext.Post throws — posting to a dispatcher that has already shut down, for instance — the exception surfaces on the thread that completed the awaited operation and the awaiting method never resumes.