void (int id, Runnable whenActive, Runnable whenCancelled) { UIUtil.invokeLaterIfNeeded(() -> { synchronized (myLock) { var active = myCurrentTask.first == id && !myCurrentTask.second.isCancelled(); (active ? whenActive : whenCancelled).run(); } }); }