void (final Project project, @NotNull final Runnable runnable, ModalityState state) { if (project != null) { ApplicationManager.getApplication().invokeAndWait(() -> { if (!project.isDisposed()) { runnable.run(); } }, state); } }