diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 7528c27..2d94009 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -211,21 +211,13 @@ private void ConvertDirectory(string path, IStorageRegistry registry, StorageFor if (!_isStarted) return; + var files = Directory.GetFiles(path, "*.qsh"); + if (!multithread) - Directory.GetFiles(path, "*.qsh").ForEach(f => ConvertFile(f, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth)); + files.ForEach(f => ConvertFile(f, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth)); else { - var tasks = new List(); - Directory.GetFiles(path, "*.qsh").ForEach(f => - { - var task = new Task(() => ConvertFile(f, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth)); - tasks.Add(task); - task.Start(); - }); - - Task.WaitAll(tasks.ToArray()); - tasks.ForEach(t => t.Dispose()); - tasks.Clear(); + Parallel.ForEach(files, file => ConvertFile(file, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth)); } //пишем имена сконвертированных в деректории файлов qsh, в файл