void (@Nullable ProgressIndicator indicator) { Application application = ApplicationManager.getApplication(); if (application.isReadAccessAllowed()) { throw new IllegalStateException("Mustn't be called from within read action"); } application.assertIsNonDispatchThread(); Semaphore semaphore = new Semaphore(1); application.invokeLater(semaphore::up, ModalityState.any()); awaitWithCheckCanceled(semaphore, indicator); }