Fixed deadlock that can happen when running as an XPC service

Replaced a call to `-performSelectorOnMainThread...` with a `dispatch_sync` call, which fixes that deadlock condition.