void () { TestTimeOut t = TestTimeOut.setTimeout(10, TimeUnit.SECONDS); while (true) { try { UIUtil.dispatchAllInvocationEvents(); } catch (Throwable e) { assertTrue(e.toString(), ExceptionUtil.causedBy(e, MyException.class)); break; } assertFalse(t.timedOut()); } }