boolean () { ProgressIndicator indicator = myProgressIndicator == null ? new EmptyProgressIndicator(creationModality) : new SensitiveProgressWrapper(myProgressIndicator) { @Override public @NotNull ModalityState getModalityState() { return creationModality; } }; if (myProgressIndicator != null) { indicator.setIndeterminate(myProgressIndicator.isIndeterminate()); } currentIndicator = indicator; try { Ref<ContextConstraint> unsatisfiedConstraint = Ref.create(); boolean success; if (ApplicationManager.getApplication().isReadAccessAllowed()) { insideReadAction(indicator, unsatisfiedConstraint); success = true; if (!unsatisfiedConstraint.isNull()) { throw new IllegalStateException("Constraint " + unsatisfiedConstraint + " cannot be satisfied"); } } else { if (myProgressIndicator != null) { try { // Give ProgressSuspender a chance to suspend now. It can't do it under a read-action myProgressIndicator.checkCanceled(); } catch (ProcessCanceledException e) { return false; } } success = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(() -> insideReadAction(indicator, unsatisfiedConstraint), indicator); } return success && unsatisfiedConstraint.isNull(); } finally { currentIndicator = null; } }