void (@NotNull ProgressIndicator indicator) { Semaphore semaphore = new Semaphore(0); //to avoid eating events and make semaphore being released we use 'this' here instead of "update" myQueue.queue(Update.create(this, () -> semaphore.release())); myQueue.flush(); try { while (true) { if (indicator.isCanceled()) break; if (semaphore.tryAcquire(100, TimeUnit.MILLISECONDS)) break; } } catch (InterruptedException e) { throw new ProcessCanceledException(e); } }