AccessToken (@NotNull Runnable runnable) { CheckCanceledHook hook = indicator -> { runnable.run(); return true; }; addCheckCanceledHook(hook); return new AccessToken() { @Override public void finish() { removeCheckCanceledHook(hook); } }; }