async Programming
Introduction
Why a Synchronization Context Is Needed
// Click handler on a button:
async void HandleButtonClicked(object sender, EventArgs args)
{
AnnounceButtonClicked();
await Task.Delay(1000);
// ----- Without a sync context, this line may run on a different thread.
button.IsEnabled = false;
}One-Line Opt-In (Recommended)
protected override void Initialize()
{
GumService.Default.Initialize(this);
GumService.Default.UseSingleThreadedAsync(); // ← this is all you need
base.Initialize();
}When Not to Call It
Manual Setup (Advanced / Pre-existing Projects)
Platform Coverage
Last updated
Was this helpful?

