void (final @NotNull Runnable runnable) { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null && progressIndicator.isModal()) { WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(runnable); } else { Application app = ApplicationManager.getApplication(); app.invokeAndWait(runnable, ModalityState.any()); } }