public void RunImport() { var channels = db.GetChannelsList(); int i = 0; foreach (ChannelDto channel in channels) { tasks[i++] = Task.Factory.StartNew(() => StartImportChannel(channel.id, channel.program_url)); } Task.WaitAll(tasks); Console.WriteLine("Removing incorrect data..."); db.DeleteProgramsWithIncorrectEndDate(); Console.WriteLine("Import has finished!"); }