void () { CountDownLatch latch = new CountDownLatch(1); ProgressManager.getInstance().run( new Task.Backgroundable(myProject, IndexingBundle.message("progress.indexing.started.as.suspended"), true) { @Override public void run(@NotNull ProgressIndicator indicator1) { try { //noinspection InfiniteLoopStatement while (true) { LockSupport.parkNanos(100_000); ProgressManager.checkCanceled(); } } finally { latch.countDown(); } } } ); ProgressIndicatorUtils.awaitWithCheckCanceled(latch); }