Skip to content

Commit 05aacf0

Browse files
committed
Improve async void guidance
1 parent 8e88a99 commit 05aacf0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

aspnetcore/blazor/components/event-handling.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ For event handling:
4040

4141
:::moniker-end
4242

43+
> [!IMPORTANT]
44+
> The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, the entire process fails when an exception isn't caught if `void` is returned. Always return a <xref:System.Threading.Tasks.Task>/<xref:System.Threading.Tasks.ValueTask> from asynchronous methods.
45+
4346
The following code:
4447

4548
* Calls the `UpdateHeading` method when the button is selected in the UI.

aspnetcore/blazor/components/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ Razor syntax for C# control structures, directives, and directive attributes are
638638

639639
### Asynchronous methods (`async`) don't support returning `void`
640640

641-
The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, exceptions aren't caught if `void` is returned. Always return a <xref:System.Threading.Tasks.Task> from asynchronous methods.
641+
The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, the entire process fails when an exception isn't caught if `void` is returned. Always return a <xref:System.Threading.Tasks.Task>/<xref:System.Threading.Tasks.ValueTask> from asynchronous methods.
642642

643643
### Nested components
644644

0 commit comments

Comments
 (0)