void () { if (!myIsRunning.compareAndSet(false, true)) return; Runnable runnable = () -> { try { while (true) { try (QueuedDumbModeTask nextTask = myTaskQueue.extractNextTask()) { if (nextTask == null) break; doRunTaskSynchronously(nextTask); } catch (ProcessCanceledException ignored) { Logger.getInstance(DumbServiceSyncTaskQueue.class).info("Canceled dumb mode task. Continue to the following task (if any)."); } } } finally { myIsRunning.set(false); } }; ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { runnable.run(); } else { ProgressManager.getInstance().runProcess(runnable, new EmptyProgressIndicator()); } }