void (@NotNull Disposable parent, @NotNull Runnable task, @Nullable ProgressIndicator parentIndicator) { final ProgressIndicator indicator = parentIndicator instanceof StandardProgressIndicator ? new SensitiveProgressWrapper(parentIndicator) : new EmptyProgressIndicator(ModalityState.defaultModalityState()); Disposable disposable = () -> { if (indicator.isRunning()) { indicator.cancel(); } }; try { ProgressManager.getInstance().runProcess(() -> { if (!registerIfParentNotDisposed(parent, disposable)) { throw new ProcessCanceledException(); } task.run(); }, indicator); } finally { Disposer.dispose(disposable); } }