void (@NotNull List<? extends Runnable> actions, @NotNull @NonNls String reason) { actions.forEach(myTasks::offer); DumbModeTask task = new MyDumbModeTask(reason, this); myProject.getMessageBus().connect(task).subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { for (RootsChangeRescanningInfo info : ((ModuleRootEventImpl)event).getInfos()) { if (info == RootsChangeRescanningInfo.TOTAL_RESCAN) { DumbService.getInstance(myProject).cancelTask(task); return; } } } }); task.queue(myProject); }