void (@NotNull Task task, @NotNull ProgressIndicator progressIndicator, @NotNull ModalityState modalityState) { if (LOG.isDebugEnabled()) LOG.debug("CoreProgressManager#runProcessWithProgressInCurrentThread, " + task, new Throwable()); if (progressIndicator instanceof Disposable) { Disposer.register(ApplicationManager.getApplication(), (Disposable)progressIndicator); } boolean processCanceled = false; Throwable exception = null; try { runProcess(() -> startTask(task, progressIndicator, null), progressIndicator); } catch (ProcessCanceledException e) { processCanceled = true; } catch (Throwable e) { exception = e; } boolean finalCanceled = processCanceled || progressIndicator.isCanceled(); Throwable finalException = exception; ApplicationUtil.invokeAndWaitSomewhere(task.whereToRunCallbacks(), modalityState, () -> finishTask(task, finalCanceled, finalException)); }