ActionCallback (@NotNull Runnable runnable, @NotNull ModalityState state, @NotNull Condition<?> expired) { if (expired.value(null)) { return ActionCallback.REJECTED; } ActionCallback callback = new ActionCallback(); LaterInvocator.invokeLater(state, Conditions.alwaysFalse(), () -> { if (!expired.value(null)) { runnable.run(); } callback.setDone(); }); return callback; }