void (final @NotNull Runnable process) { Runnable toRun = runInReadAction ? () -> { if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(process)) { failedSubTasks.add(this); doComplete(throwable); } } : process; ProgressManager progressManager = ProgressManager.getInstance(); ProgressIndicator existing = progressManager.getProgressIndicator(); if (existing == progressIndicator) { // we are already wrapped in an indicator - most probably because we came here from helper which steals children tasks toRun.run(); } else { progressManager.executeProcessUnderProgress(toRun, progressIndicator); } }