Shutdown the event dispatch at the end of our current dispatch queue
()
| 73 | * Shutdown the event dispatch at the end of our current dispatch queue |
| 74 | */ |
| 75 | public static |
| 76 | void shutdown() { |
| 77 | // we have to make sure we shut down on our own thread (and not the JavaFX/SWT/AWT/etc thread) |
| 78 | runLater(()->{ |
| 79 | ExecutorService executorService = null; |
| 80 | synchronized (EventDispatch.class) { |
| 81 | executorService = eventDispatchExecutor; |
| 82 | eventDispatchExecutor = null; |
| 83 | } |
| 84 | |
| 85 | if (executorService != null) { |
| 86 | final List<Runnable> runnables = executorService.shutdownNow(); |
| 87 | for (int i = 0; i < runnables.size(); i++) { |
| 88 | try { |
| 89 | runnables.get(i) |
| 90 | .run(); |
| 91 | } catch (Exception e) { |
| 92 | SystemTray.logger.error("Error shutting down EventDispatch", e); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | shutdownLatch.countDown(); |
| 97 | } |
| 98 | }); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Waits for the event dispatch to finish shutting down |