private void Prehash(string dir, WorkWindow wwin, string fname) { IEnumerable <string> files = Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories) .Where(file => file.EndsWith(".png") || file.EndsWith(".jpg") || file.EndsWith(".jpeg")); ParallelOptions opts = new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount - 1 }; int idx = 0; int total = files.Count(); Parallel.ForEach(files, opts, (file) => { wwin.SetPBarScore(idx, total); wwin.SetSecondaryMessage($"BUILDING CACHE...\n [{idx}] out of [{files.Count()}]"); BitmapComparer.CacheDiff(file); idx++; }); BitmapComparer.SaveDiffCacheToDisk(fname); }