@@ -150,10 +150,6 @@ protected async Task RenderRootComponentAsync(int componentId, ParameterCollecti
150
150
try
151
151
{
152
152
await ProcessAsynchronousWork ( ) ;
153
- if ( _pendingTasks . Count != 0 )
154
- {
155
- throw new Exception ( ) ;
156
- }
157
153
Debug . Assert ( _pendingTasks . Count == 0 ) ;
158
154
}
159
155
finally
@@ -276,8 +272,7 @@ public virtual Task InvokeAsync(Func<Task> workItem)
276
272
// This is for example when we run on a system with a single thread, like WebAssembly.
277
273
if ( _dispatcher == null )
278
274
{
279
- workItem ( ) ;
280
- return Task . CompletedTask ;
275
+ return workItem ( ) ;
281
276
}
282
277
283
278
if ( SynchronizationContext . Current == _dispatcher )
@@ -420,7 +415,10 @@ private void ProcessRenderQueue()
420
415
421
416
var batch = _batchBuilder . ToBatch ( ) ;
422
417
updateDisplayTask = UpdateDisplayAsync ( batch ) ;
423
- InvokeRenderCompletedCalls ( batch . UpdatedComponents ) ;
418
+
419
+ // Fire off the execution of OnAfterRenderAsync, but don't wait for it
420
+ // if there is async work to be done.
421
+ _ = InvokeRenderCompletedCalls ( batch . UpdatedComponents ) ;
424
422
}
425
423
finally
426
424
{
@@ -430,7 +428,7 @@ private void ProcessRenderQueue()
430
428
}
431
429
}
432
430
433
- private async void InvokeRenderCompletedCalls ( ArrayRange < RenderTreeDiff > updatedComponents )
431
+ private Task InvokeRenderCompletedCalls ( ArrayRange < RenderTreeDiff > updatedComponents )
434
432
{
435
433
List < Task > batch = null ;
436
434
var array = updatedComponents . Array ;
@@ -466,10 +464,9 @@ private async void InvokeRenderCompletedCalls(ArrayRange<RenderTreeDiff> updated
466
464
}
467
465
}
468
466
469
- if ( batch != null )
470
- {
471
- await Task . WhenAll ( batch ) ;
472
- }
467
+ return batch != null ?
468
+ Task . WhenAll ( batch ) :
469
+ Task . CompletedTask ;
473
470
}
474
471
475
472
private void RenderInExistingBatch ( RenderQueueEntry renderQueueEntry )
0 commit comments