void () { ProgressIndicator outerIndicator = new EmptyProgressIndicator(); CancellablePromise<Object> promise = ReadAction .nonBlocking(() -> { //noinspection InfiniteLoopStatement while (true) { ProgressManager.getInstance().getProgressIndicator().checkCanceled(); } }) .wrapProgress(outerIndicator) .submit(AppExecutorUtil.getAppExecutorService()); outerIndicator.cancel(); waitForPromise(promise); }