Created
August 7, 2012 10:40
-
-
Save philcockfield/3284433 to your computer and use it in GitHub Desktop.
EnsureInvokedOnMainThread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void EnsureInvokedOnMainThread(Action action) | |
{ | |
if (IsMainThread()) | |
{ | |
action(); | |
return; | |
} | |
this.BeginInvokeOnMainThread(() => action()); | |
} | |
private static IntPtr GetClassHandle(string clsName) | |
{ | |
return (new Class(clsName)).Handle; | |
} | |
private static bool IsMainThread() | |
{ | |
return Messaging.bool_objc_msgSend(GetClassHandle("NSThread"), new Selector("isMainThread").Handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment