Skip to content

Commit f19a744

Browse files
committed
Fix test failure
1 parent 57dc18d commit f19a744

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/Components/Components/src/Rendering/Renderer.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ protected async Task RenderRootComponentAsync(int componentId, ParameterCollecti
150150
try
151151
{
152152
await ProcessAsynchronousWork();
153-
if (_pendingTasks.Count != 0)
154-
{
155-
throw new Exception();
156-
}
157153
Debug.Assert(_pendingTasks.Count == 0);
158154
}
159155
finally
@@ -276,8 +272,7 @@ public virtual Task InvokeAsync(Func<Task> workItem)
276272
// This is for example when we run on a system with a single thread, like WebAssembly.
277273
if (_dispatcher == null)
278274
{
279-
workItem();
280-
return Task.CompletedTask;
275+
return workItem();
281276
}
282277

283278
if (SynchronizationContext.Current == _dispatcher)
@@ -420,7 +415,10 @@ private void ProcessRenderQueue()
420415

421416
var batch = _batchBuilder.ToBatch();
422417
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);
424422
}
425423
finally
426424
{
@@ -430,7 +428,7 @@ private void ProcessRenderQueue()
430428
}
431429
}
432430

433-
private async void InvokeRenderCompletedCalls(ArrayRange<RenderTreeDiff> updatedComponents)
431+
private Task InvokeRenderCompletedCalls(ArrayRange<RenderTreeDiff> updatedComponents)
434432
{
435433
List<Task> batch = null;
436434
var array = updatedComponents.Array;
@@ -466,10 +464,9 @@ private async void InvokeRenderCompletedCalls(ArrayRange<RenderTreeDiff> updated
466464
}
467465
}
468466

469-
if (batch != null)
470-
{
471-
await Task.WhenAll(batch);
472-
}
467+
return batch != null ?
468+
Task.WhenAll(batch) :
469+
Task.CompletedTask;
473470
}
474471

475472
private void RenderInExistingBatch(RenderQueueEntry renderQueueEntry)

0 commit comments

Comments
 (0)