void () { // We know at least about one use-case that requires special treatment here: many short (in terms of time) progress tasks are // executed in a small amount of time. Problem: UI blinks and looks ugly if we show progress dialog that disappears shortly // for each of them. The solution is to postpone the tasks of showing progress dialog. Hence, it will not be shown at all // if the task is already finished when the time comes. EdtScheduledExecutorService.getInstance().schedule((ContextAwareRunnable) () -> { // The `ContextAwareRunnable` here is actually wrong, but it is necessary now to prevent cancellation from leaked job from the context. if (isRunning()) { showDialog(); } else if (isPopupWasShown()) { Disposer.dispose(this); } }, getModalityState(), myDelayInMillis, TimeUnit.MILLISECONDS); }