void (@NotNull final Processor<? super Usage> processor) { Runnable runnable = () -> { myIndicator.setIndeterminate(true); //noinspection DialogTitleCapitalization myIndicator.setText2(FindBundle.message("find.searching.for.string.in.file.occurrences.progress", 0)); final CountProcessor counter = new CountProcessor(); myScope.iterateContent(myProject, counter); myIndicator.setIndeterminate(false); myIndicator.setFraction(0); myScope.iterateContent(myProject, new MyProcessor(processor, counter.getFileCount())); }; ApplicationManager.getApplication().runReadAction(runnable); }