METHOD
MainThread.InvokeOnMainThreadAsync
Runs an action or supported asynchronous delegate on the application main thread and returns a task. Check page/window lifetime inside the update. Requires a compatible MAUI target and actual main-thread environment.
Formal Syntax & Structure
csharp syntaxcsharp
await MainThread.InvokeOnMainThreadAsync(action)Working Example
Example Snippetcsharp
using System;using System.ComponentModel;using System.Collections.ObjectModel;using System.Windows.Input;using Microsoft.Maui.ApplicationModel;// Partial MAUI snippet in a live page.await MainThread.InvokeOnMainThreadAsync(()=>Status.Text="Ready");