void DoReparseCode(List <FileName> filesToParse, IProgressMonitor progressMonitor) { ParseableFileContentFinder finder = new ParseableFileContentFinder(); double fileCountInverse = 1.0 / filesToParse.Count; object progressLock = new object(); Parallel.ForEach( filesToParse, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = progressMonitor.CancellationToken }, fileName => { // Clear cached parse information so that the file is forced to be reparsed even if it is unchanged parserService.ClearParseInformation(fileName); ITextSource content = finder.Create(fileName); if (content != null) { parserService.ParseFile(fileName, content, project); } lock (progressLock) { progressMonitor.Progress += fileCountInverse; } }); }