void (@NotNull Supplier<String> errorMessageSupplier, @NotNull BooleanSupplier condition, int timeoutInSeconds, @Nullable Runnable callback) { long start = System.currentTimeMillis(); while (true) { try { if (System.currentTimeMillis() - start > timeoutInSeconds * 1000L) { if (callback != null) { callback.run(); } fail(errorMessageSupplier.get()); } if (condition.getAsBoolean()) { if (callback != null) { callback.run(); } break; } dispatchAllEventsInIdeEventQueue(); //noinspection BusyWait Thread.sleep(10); } catch (InterruptedException e) { throw new RuntimeException(e); } } }