In components event dispatch, use explicit fire-and-forget instead of async void (#10149)

This commit is contained in:
Steve Sanderson 2019-05-10 18:12:32 +01:00 committed by GitHub
parent 0a148bfca4
commit efa9a4e530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -152,13 +152,16 @@ namespace Microsoft.AspNetCore.Blazor.Rendering
if (deferredIncomingEvents.Count > 0) if (deferredIncomingEvents.Count > 0)
{ {
ProcessNextDeferredEvent(); // Fire-and-forget because the task we return from this method should only reflect the
// completion of its own event dispatch, not that of any others that happen to be queued.
// Also, ProcessNextDeferredEventAsync deals with its own async errors.
_ = ProcessNextDeferredEventAsync();
} }
} }
} }
} }
private async void ProcessNextDeferredEvent() private async Task ProcessNextDeferredEventAsync()
{ {
var info = deferredIncomingEvents.Dequeue(); var info = deferredIncomingEvents.Dequeue();
var taskCompletionSource = info.TaskCompletionSource; var taskCompletionSource = info.TaskCompletionSource;