[SimpleSort] This can be multithreaded...

This commit is contained in:
Matt Nadareski
2016-10-17 15:08:49 -07:00
parent d433e81d60
commit b9d8ce356c

View File

@@ -209,8 +209,9 @@ namespace SabreTools.Helper
// Create a list of just files from inputs // Create a list of just files from inputs
List<string> files = new List<string>(); List<string> files = new List<string>();
foreach (string input in _inputs) Parallel.ForEach(_inputs,
{ new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism, },
input => {
if (File.Exists(input)) if (File.Exists(input))
{ {
_logger.Verbose("File found: '" + input + "'"); _logger.Verbose("File found: '" + input + "'");
@@ -219,17 +220,19 @@ namespace SabreTools.Helper
else if (Directory.Exists(input)) else if (Directory.Exists(input))
{ {
_logger.Verbose("Directory found: '" + input + "'"); _logger.Verbose("Directory found: '" + input + "'");
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories)) Parallel.ForEach(Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories),
new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism, },
file =>
{ {
_logger.Verbose("File found: '" + file + "'"); _logger.Verbose("File found: '" + file + "'");
files.Add(Path.GetFullPath(file)); files.Add(Path.GetFullPath(file));
} });
} }
else else
{ {
_logger.Error("'" + input + "' is not a file or directory!"); _logger.Error("'" + input + "' is not a file or directory!");
} }
} });
_logger.User("Retrieving complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); _logger.User("Retrieving complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Then, loop through and check each of the inputs // Then, loop through and check each of the inputs