+ @Override
+ public TimerTask schedule(Runnable task, long delay) {
+ TimerTask timerTask = newSwtUxTimerTask(task);
+ uxTimer.schedule(timerTask, delay);
+ return timerTask;
+ }
+
+ @Override
+ public TimerTask schedule(Runnable task, long delay, long period) {
+ TimerTask timerTask = newSwtUxTimerTask(task);
+ uxTimer.schedule(timerTask, delay, period);
+ return timerTask;
+ }
+
+ protected TimerTask newSwtUxTimerTask(Runnable todo) {
+ return new TimerTask() {
+
+ @Override
+ public void run() {
+ synchronized (display) {
+ try {
+ if (!display.isDisposed()) {
+ display.syncExec(() -> {
+ todo.run();
+ });
+ }
+ } catch (Exception e) {
+ log.error("Cannot run UX timer task", e);
+ }
+ }
+ }
+ };
+ }