public async Task ExecuteAllAsync(string[] lines) { List <Task> tasks = new List <Task>(); foreach (String line in lines) { List <string> splitLine = Regex.Matches(line, @"[\""].+?[\""]|[^ ]+") .Cast <Match>() .Select(m => m.Value.Replace("\"", "")) .ToList(); string commandName = splitLine.ElementAt(0); splitLine.RemoveAt(0); Command command = GetCommand(commandName); if (command.Concurrent) { Task task = command.ExecuteAsync(splitLine); tasks.Add(task); } else { await command.ExecuteAsync(splitLine); } } await Task.WhenAll(tasks); }
public async Task ExecuteAsync(string line) { SeparateCommandNameAndArguments(line, out List <string> splitLine, out string commandName); Command command = GetCommand(commandName); await command.ExecuteAsync(splitLine); }