Skip to content

Commit 5194b10

Browse files
committed
feedback/comments
1 parent 75044b1 commit 5194b10

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Diff for: src/Components/Components/src/RenderTree/Renderer.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,14 @@ private void HandleExceptionViaErrorBoundary(Exception error, ComponentState? er
11031103
/// <param name="disposing"><see langword="true"/> if this method is being invoked by <see cref="IDisposable.Dispose"/>, otherwise <see langword="false"/>.</param>
11041104
protected virtual void Dispose(bool disposing)
11051105
{
1106+
// in theory multiple threads could be racing for this
11061107
lock (_lockObject)
11071108
{
11081109
if (_rendererIsDisposed)
11091110
{
1111+
// quitting synchronously as soon as possible is avoiding
1112+
// possible async dispatch to another thread and
1113+
// possible deadlock on synchronous `done.Wait()` below.
11101114
return;
11111115
}
11121116
}

Diff for: src/Components/Components/test/Rendering/RendererSynchronizationContextTest.cs

+3
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ public async Task InvokeAsync_SyncWorkInAsyncTaskIsCompletedFirst()
771771
await Task.Yield();
772772
actual = "First";
773773

774+
// this test assumes RendererSynchronizationContext optimization, which makes it synchronous execution.
775+
// with multi-threading runtime and WebAssemblyDispatcher `InvokeAsync` will be executed asynchronously ordering it differently.
776+
// See https://github.com/dotnet/aspnetcore/pull/52724#issuecomment-1895566632
774777
var invokeTask = context.InvokeAsync(async () =>
775778
{
776779
// When the sync context is idle, queued work items start synchronously

Diff for: src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public void CanDispatchAsyncWorkToSyncContext()
2727

2828
appElement.FindElement(By.Id("run-async-with-dispatch")).Click();
2929

30+
// this test assumes RendererSynchronizationContext optimization, which makes it synchronous execution.
31+
// with multi-threading runtime and WebAssemblyDispatcher `InvokeAsync` will be executed asynchronously ordering it differently.
32+
// See https://github.com/dotnet/aspnetcore/pull/52724#issuecomment-1895566632
3033
Browser.Equal("First Second Third Fourth Fifth", () => result.Text);
3134
}
3235
}

0 commit comments

Comments
 (0)