void (boolean synchronous, @NotNull Runnable task) { final Application app = ApplicationManager.getApplication(); if (app.isDispatchThread()) { task.run(); return; } if (synchronous) { app.invokeAndWait(task); } else { app.invokeLater(task); } }