<PackageReference Include="Nito.AsyncEx.Tasks" Version="2.0.0-alpha-01" />

Nito.AsyncEx.SynchronizationContextSwitcher

public sealed class SynchronizationContextSwitcher : SingleDisposable<object>
Utility class for temporarily switching SynchronizationContext implementations.

Initializes a new instance of the SynchronizationContextSwitcher class, installing the new SynchronizationContext.

public static void NoContext(Action action)

Executes a synchronous delegate without the current SynchronizationContext. The current context is restored when this function returns.

public static Task NoContextAsync(Func<Task> action)

Executes an asynchronous delegate without the current SynchronizationContext. The current context is restored when this function returns its task.