.NET MAUI › Networking & APIs
How do you keep API calls off the UI thread and update the UI safely?
IntermediateAnswer
Await async HttpClient calls—they run I/O off the UI thread already. When you must marshal a result back to the UI from a non-UI context, use MainThread.BeginInvokeOnMainThread. Binding updates from async view-model code are marshaled by MAUI, but explicit UI mutations must be on the main thread.
var data = await _api.GetAsync(); // off UI thread
MainThread.BeginInvokeOnMainThread(() => Items.Add(data));Real-world example A background refresh fetches data without freezing the UI, then updates an observable collection on the main thread.