Skip to content

Commit e4fc49c

Browse files
Move the new section below the CAUTION note
1 parent e03af3f commit e4fc49c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/csharp/asynchronous-programming/start-multiple-async-tasks-and-process-them-as-they-complete.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ For any given URL, the method will use the `client` instance provided to get the
166166

167167
Run the program several times to verify that the downloaded lengths don't always appear in the same order.
168168

169+
> [!CAUTION]
170+
> You can use `WhenAny` in a loop, as described in the example, to solve problems that involve a small number of tasks. However, other approaches are more efficient if you have a large number of tasks to process. For more information and examples, see [Processing tasks as they complete](https://devblogs.microsoft.com/pfxteam/processing-tasks-as-they-complete).
171+
169172
## Simplify the approach using `Task.WhenEach`
170173

171174
The `while` loop implemented in `SumPageSizesAsync` method can be simplified using the new <xref:System.Threading.Tasks.Task.WhenEach%2A?displayProperty=nameWithType> method introduced in .NET 9, by calling it in `await foreach` loop.
@@ -189,9 +192,6 @@ with the simplified `await foreach`:
189192
}
190193
```
191194

192-
> [!CAUTION]
193-
> You can use `WhenAny` in a loop, as described in the example, to solve problems that involve a small number of tasks. However, other approaches are more efficient if you have a large number of tasks to process. For more information and examples, see [Processing tasks as they complete](https://devblogs.microsoft.com/pfxteam/processing-tasks-as-they-complete).
194-
195195
## Complete example
196196

197197
The following code is the complete text of the *Program.cs* file for the example.

0 commit comments

Comments
 (0)