# `SynchronizationContextSwitcher` ```csharp public static class SynchronizationContextSwitcher { public record Switcher(SynchronizationContext? Context) : INotifyCompletion { public bool IsCompleted => Context == null || ReferenceEquals(SynchronizationContext.Current, Context); public void OnCompleted(Action continuation) => Context?.Post(_ => continuation(), null); public void GetResult() { } public Switcher GetAwaiter() => this; } public static Switcher SwitchTo(SynchronizationContext? context) => new(context); } ``` ## Sources - [Explicitly switch to the UI thread in an async method](https://thomaslevesque.com/2015/11/11/explicitly-switch-to-the-ui-thread-in-an-async-method/)