void (final boolean initIfEmpty, final boolean inBackground) { final Runnable task = () -> { Collection<ChangesCacheFile> files = myCachesHolder.getAllCaches(); final RefreshResultConsumer notifyConsumer = new RefreshResultConsumer() { private VcsException myError = null; private int myCount = 0; private int totalChangesCount = 0; @Override public void receivedChanges(List<CommittedChangeList> changes) { totalChangesCount += changes.size(); checkDone(); } @Override public void receivedError(VcsException ex) { myError = ex; checkDone(); } private void checkDone() { myCount++; if (myCount == files.size()) { myTaskQueue.run(() -> { if (totalChangesCount > 0) { notifyReloadIncomingChanges(); } else { myProject.getMessageBus().syncPublisher(CommittedChangesTreeBrowser.ITEMS_RELOADED).emptyRefresh(); } }); notifyRefreshError(myError); } } }; for(ChangesCacheFile file: files) { if ((! inBackground) || file.getVcs().isVcsBackgroundOperationsAllowed(file.getRootPath().getVirtualFile())) { refreshCacheAsync(file, initIfEmpty, notifyConsumer, false); } } }; myTaskQueue.run(task); }