void invokeAndWait ( final Runnable r ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; queue . postRunnable ( ( ) -> { try { r . run ( ) ; } finally { latch . countDown ( ) ; } } ) ; try { latch . await ( ) ; } catch ( InterruptedException e ) { } }
Posts a Runnable to the JavaFX event queue and waits for the Runnable to complete .