Xamarin.Forms Guides | Samples

Xamarin.Forms.Device.BeginInvokeOnMainThread Method

Invokes an Action on the device main (UI) thread.

Syntax

public static Void BeginInvokeOnMainThread (Action action)

Parameters

action
The Action to invoke

Remarks

This example shows how to set the Text of Label on the main thread, e.g. in response to an async event.

C# Example

Device.BeginInvokeOnMainThread (() => {
  label.Text = "Async operation completed";
});

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0