void () { Disposable listenerDisposable = Disposer.newDisposable(); ApplicationManager.getApplication().addApplicationListener(new ApplicationListener() { @Override public void afterWriteActionFinished(@NotNull Object action) { try { processQueue(); } finally { Disposer.dispose(listenerDisposable); } } }, listenerDisposable); }