public void SynchFilesRead(List <string> filesPaths) { var timer = Stopwatch.StartNew(); var synch = new SyncExample(); foreach (var path in filesPaths) { var r = synch.ReedThisFile(path); Console.WriteLine(r.ThreadId); Console.WriteLine(r.ActionMessage); Console.WriteLine("__________________________"); } timer.Stop(); Console.WriteLine($"Finished, Time: {timer.Elapsed}"); }
public void ParallelFilesRead(List <string> filesPaths) { var timer = Stopwatch.StartNew(); var sy = new SyncExample(); var tasks = new List <Task <TheResponse> >(); Parallel.ForEach(filesPaths, p => { var r = sy.ReedThisFile(p); Console.WriteLine(r.ThreadId); Console.WriteLine(r.ActionMessage); Console.WriteLine("__________________________"); }); timer.Stop(); Console.WriteLine($"Finished, Time: {timer.Elapsed}"); }