void (@NotNull final AbstractCommand command) { CountDownLatch myLatch = new CountDownLatch(1); ApplicationManager.getApplication().executeOnPooledThread(() -> { if (command instanceof ResumeOrStepCommand) { final String threadId = ((ResumeOrStepCommand)command).getThreadId(); clearTempVariables(threadId); } try { command.execute(); } catch (Exception e) { LOG.error(e); } finally { myLatch.countDown(); } }); if (command.isResponseExpected()) { ApplicationManager.getApplication().assertIsNonDispatchThread(); // Note: do not wait for result from UI thread try { myLatch.await(command.getResponseTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { // restore interrupted flag Thread.currentThread().interrupt(); LOG.error(e); } } }