[Issue #2412] Replacing performSelectorOnMainThread: with dispatch_sync to main queue to fix issue when using in XPC service