This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Assume we have a list of tasks and we need to run them asynchronously, we can use below code: | |
| var toDoTasks = new List<OurTask>(); | |
| IEnumerable<Task<int>> taskListQuery = from toDoTask in toDoTasks select DoSomething(ourTask); | |
| List<Task<int>> taskList = taskListQuery.ToList(); | |
| while (taskList.Count > 0) | |
| { | |
| Task<int> firstFinishedTask = await Task.WhenAny(taskList); |