iOS Guides | Samples

MonoTouch.Foundation.NSObject.InvokeOnMainThread Method

Invokes synchronously the specified code on the main UI thread.


public Void InvokeOnMainThread (NSAction action)


The code to invoke on the main thread.


You use this method from a thread to invoke the code encapsulated by the NSAction delegate 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 NSObject.BeginInvokeOnMainThread(NSAction) this method waits for the main thread to execute the method, and does not return until the code pointed by action has completed running.


Namespace: MonoTouch.Foundation
Assembly: monotouch (in monotouch.dll)
Assembly Versions: