void () { assert ApplicationManager.getApplication().isUnitTestMode(); final Semaphore semaphore = new Semaphore(); semaphore.down(); myScheduler.submit(semaphore::up); if (ApplicationManager.getApplication().isDispatchThread()) { while (!semaphore.waitFor(100)) { UIUtil.dispatchAllInvocationEvents(); } } else { semaphore.waitFor(); } }