mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-11-04 12:58:38 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			18 lines
		
	
	
		
			435 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			435 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
export function dispatchToMainThread(func: () => void) {
 | 
						|
	NSOperationQueue.mainQueue.addOperationWithBlock(func);
 | 
						|
}
 | 
						|
 | 
						|
export function isMainThread(): boolean {
 | 
						|
	return NSThread.isMainThread;
 | 
						|
}
 | 
						|
 | 
						|
export function dispatchToUIThread(func: () => void) {
 | 
						|
	const runloop = CFRunLoopGetMain();
 | 
						|
	if (runloop && func) {
 | 
						|
		CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, func);
 | 
						|
		CFRunLoopWakeUp(runloop);
 | 
						|
	} else if (func) {
 | 
						|
		func();
 | 
						|
	}
 | 
						|
}
 |