void (ProgressIndicator indicator, Runnable runnable) { if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> { indicator.checkCanceled(); runnable.run(); })) { indicator.cancel(); indicator.checkCanceled(); } }