NSObject.InvokeOnMainThread NSObject.InvokeOnMainThread Method

Definition

Overloads

InvokeOnMainThread(Action) InvokeOnMainThread(Action)
InvokeOnMainThread(Selector, NSObject) InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

InvokeOnMainThread(Action) InvokeOnMainThread(Action)

public void InvokeOnMainThread (Action action);
member this.InvokeOnMainThread : Action -> unit

Parameters

action
Action Action

InvokeOnMainThread(Selector, NSObject) InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

public void InvokeOnMainThread (ObjCRuntime.Selector sel, Foundation.NSObject obj);
member this.InvokeOnMainThread : ObjCRuntime.Selector * Foundation.NSObject -> unit

Parameters

sel
Selector Selector

Selector to invoke

obj
NSObject NSObject

Object in which the selector is invoked

Remarks

You use this method from a thread to invoke the code in the specified object that is exposed with the specified selector in the UI thread. This is required for most operations that affect UIKit or AppKit as neither one of those APIs is thread safe.

The code is executed when the main thread goes back to its main loop for processing events.

Unlike BeginInvokeOnMainThread(Selector, NSObject) this method waits for the main thread to execute the method, and does not return until the code pointed by action has completed.

Applies to