I may be misunderstanding the purpose of your code, but if all you need is make sure that a part of your code is called on the message thread, wait for its completion, then move along on whatever thread you already were, you could make use of callFunctionOnMessageThread()