static void Main(string[] args) { _cmdArgs = new CommandArgs(); if (!_cmdArgs.ParseArgs(args)) return; // Remove all SKYD files foreach (var skydFile in Directory.EnumerateFiles(Path.GetDirectoryName(_cmdArgs.FilePath) ?? string.Empty, "*.skyd")) { try { File.Delete(skydFile); } catch (Exception) { Console.Error.WriteLine("Error: Failed to remove existing file {0}", skydFile); return; } } _stopwatch = new Stopwatch(); _stopwatch.Start(); _queue = new QueueWorker<List<string>>(Run); _queue.RunAsync(_cmdArgs.Processes, "Start Skyline"); string dataFilter = "*.*"; if (!string.IsNullOrEmpty(_cmdArgs.DataFilter)) dataFilter = _cmdArgs.DataFilter; string dataDir = "."; if (!string.IsNullOrEmpty(_cmdArgs.DataDir)) dataDir = _cmdArgs.DataDir; var fileGroupCurrent = new List<string>(); var fileGroups = new List<List<string>> {fileGroupCurrent}; var dataFiles = Directory.EnumerateFiles(dataDir, dataFilter).ToArray(); int filesPerProcess = (int) Math.Ceiling(((double) dataFiles.Length)/_cmdArgs.Processes); foreach (var dataFile in dataFiles) { if (fileGroupCurrent.Count >= filesPerProcess) { fileGroupCurrent = new List<string>(); fileGroups.Add(fileGroupCurrent); } fileGroupCurrent.Add(dataFile); } _queue.Add(fileGroups, true); Console.WriteLine("Elapsed time: " + _stopwatch.Elapsed.ToString(@"mm\:ss")); }
private void btnStart_Click(object sender, EventArgs e) { btnStart.Enabled = false; _timeColor = lblTime.ForeColor; lblTime.ForeColor = Color.Red; _stopwatch = new Stopwatch(); _stopwatch.Start(); _timer = new Timer {Interval = 500}; _timer.Tick += (s, e1) => lblTime.Text = _stopwatch.Elapsed.ToString(@"mm\:ss"); // Not L10N _timer.Start(); if (File.Exists(SkydFile)) File.Delete(SkydFile); _log = Log.Replace("#", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")); _dataDir = Path.Combine(RootDir, comboModel.Text); _uiIndex = comboUI.SelectedIndex; _queue = new QueueWorker<string>(Run) {CompleteAction = RunFinished}; _queue.RunAsync((int) numericMaxProcesses.Value, "Start Skyline"); _queue.Add(Directory.EnumerateFiles(_dataDir, comboModel.Text == "wiff" ? "*.wiff" : "*.mz5")); }