void (@NotNull ProgressIndicator indicator) { myIsRunning = true; try { service().runTaskSynchronously(new DumbModeTask() { @Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { //the task execution must be postponed, so the captured closure will evaluate to `false` myInnerRunning.set(myIsRunning); } }); } finally { myIsRunning = false; } }