public ConsoleProgram(IEnumerable <string> logFiles) { if (ProgramHelper.ParseMultipleLogs()) { var splitLogFiles = new List <List <string> >(); var sizeSortedLogFiles = new List <string>(logFiles); for (int i = 0; i < ProgramHelper.GetMaxParallelRunning(); i++) { splitLogFiles.Add(new List <string>()); } sizeSortedLogFiles.Sort((x, y) => { var fInfoX = new FileInfo(x); long xValue = fInfoX.Exists ? fInfoX.Length : 0; var fInfoY = new FileInfo(y); long yValue = fInfoY.Exists ? fInfoY.Length : 0; return(xValue.CompareTo(yValue)); }); int index = 0; foreach (string file in sizeSortedLogFiles) { splitLogFiles[index].Add(file); index = (index + 1) % ProgramHelper.GetMaxParallelRunning(); } Parallel.ForEach(splitLogFiles, files => { foreach (string file in files) { ParseLog(file); } }); } else { foreach (string file in logFiles) { ParseLog(file); } } }
/// <summary> /// Queues an operation. If the 'MultipleLogs' setting is true, operations are run asynchronously /// </summary> /// <param name="operation"></param> private void QueueOrRunOperation(FormOperationController operation) { btnClearAll.Enabled = false; btnParse.Enabled = false; btnCancelAll.Enabled = true; if (Properties.Settings.Default.ParseMultipleLogs && _runningCount < ProgramHelper.GetMaxParallelRunning()) { _RunOperation(operation); } else { if (_anyRunning) { _logQueue.Enqueue(operation); operation.ToPendingState(); } else { _RunOperation(operation); } } }
/// <summary> /// Queues an operation. If the 'MultipleLogs' setting is true, operations are run asynchronously /// </summary> /// <param name="operation"></param> private void QueueOrRunOperation(FormOperationController operation) { BtnClearAll.Enabled = false; BtnParse.Enabled = false; BtnCancelAll.Enabled = true; BtnDiscordBatch.Enabled = false; ChkAutoDiscordBatch.Enabled = false; if (ProgramHelper.ParseMultipleLogs() && _runningCount < ProgramHelper.GetMaxParallelRunning()) { _RunOperation(operation); } else { if (_anyRunning) { _logQueue.Enqueue(operation); operation.ToPendingState(); } else { _RunOperation(operation); } } }