public async Task AddFiles(string[] collection) { Task task = Task.Run(() => { foreach (string path in collection) { BatchItem item = new BatchItem() { Actions = Functions }; if (BatchPath.IsDirectory(path)) { item.Target = new BatchDirectory(path); } if (BatchPath.IsFile(path)) { item.Target = new BatchFile(path); } Items.Add(item); item.Commit(); } RefreshDisplay(); }); await task; }