mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: added Utils.executeOnUIThread
This commit is contained in:
@@ -5,3 +5,15 @@ export function dispatchToMainThread(func: () => void) {
|
||||
export function isMainThread(): boolean {
|
||||
return NSThread.isMainThread;
|
||||
}
|
||||
|
||||
export function dispatchToUIThread(func: () => void) {
|
||||
const runloop = CFRunLoopGetMain();
|
||||
return function (func) {
|
||||
if (runloop && func) {
|
||||
CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, func);
|
||||
CFRunLoopWakeUp(runloop);
|
||||
} else if (func) {
|
||||
func();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user