void (@NotNull Disposable disposable, @NotNull ProgressIndicator progressIndicator) { // avoid "attach listener"/"write action" race ReadAction.run(() -> { progressIndicator.start(); ProgressIndicatorUtils.forceWriteActionPriority(progressIndicator, disposable); // there is a chance we are racing with write action, in which case just registered listener might not be called, retry. if (ApplicationManagerEx.getApplicationEx().isWriteActionPending()) { throw new ProcessCanceledException(); } }); }