Skip to content

Commit bfea872

Browse files
authored
[browser][MT] fix .Wait in CompleteTask (#101078)
1 parent 42f2b33 commit bfea872

File tree

2 files changed

+4
-3
lines changed
  • src/libraries/System.Runtime.InteropServices.JavaScript

2 files changed

+4
-3
lines changed

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,11 @@ public static void CompleteTask(JSMarshalerArgument* arguments_buffer)
203203
}
204204
}
205205

206-
// this is always running on I/O thread, so it will not throw PNSE
207206
// it's also OK to block here, because we know we will only block shortly, as this is just race with the other thread.
208-
holder.CallbackReady?.Wait();
207+
if (holder.CallbackReady != null)
208+
{
209+
Thread.ForceBlockingWait(static (b) => ((ManualResetEventSlim)b!).Wait(), holder.CallbackReady);
210+
}
209211

210212
lock (ctx)
211213
{

src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.WebSocket.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ await executor.Execute(async () =>
3939

4040

4141
[Theory, MemberData(nameof(GetTargetThreads2x))]
42-
[ActiveIssue("https://github.com/dotnet/runtime/issues/100931")]
4342
public async Task WebSocketClient_ResponseCloseInDifferentThread(Executor executor1, Executor executor2)
4443
{
4544
using var cts = CreateTestCaseTimeoutSource();

0 commit comments

Comments
 (0)