void () { // project must be disposed in EDT in write action Runnable doDispose = () -> { if (isCached()) { WriteAction.run(() -> super.dispose()); } }; ModalityUiUtil.invokeLaterIfNeeded(ModalityState.nonModal(), myParentDisposable.getDisposed(), doDispose); }