Skip to content

Commit c89c23d

Browse files
authored
attempt to fix #98406 (#99317)
1 parent b5b290f commit c89c23d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSProxyContext.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,14 @@ public nint AllocJSVHandle()
280280
{
281281
lock (this)
282282
{
283+
ObjectDisposedException.ThrowIf(_isDisposed, this);
284+
283285
if (JSVHandleFreeList.Count > 0)
284286
{
285287
var jsvHandle = JSVHandleFreeList[JSVHandleFreeList.Count - 1];
286288
JSVHandleFreeList.RemoveAt(JSVHandleFreeList.Count - 1);
287289
return jsvHandle;
288290
}
289-
if (NextJSVHandle == IntPtr.Zero)
290-
{
291-
NextJSVHandle = -2;
292-
}
293291
return NextJSVHandle--;
294292
}
295293
}

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ internal void ToJSDynamic(Task? value)
189189
var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle);
190190

191191
#if FEATURE_WASM_MANAGED_THREADS
192-
task.ContinueWith(Complete, taskHolder, TaskScheduler.FromCurrentSynchronizationContext());
192+
task.ContinueWith(Complete, taskHolder, CancellationToken.None, TaskContinuationOptions.RunContinuationsAsynchronously, TaskScheduler.FromCurrentSynchronizationContext());
193193
#else
194194
task.ContinueWith(Complete, taskHolder, TaskScheduler.Current);
195195
#endif
@@ -273,7 +273,7 @@ public void ToJS(Task? value)
273273
var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle);
274274

275275
#if FEATURE_WASM_MANAGED_THREADS
276-
task.ContinueWith(Complete, taskHolder, TaskScheduler.FromCurrentSynchronizationContext());
276+
task.ContinueWith(Complete, taskHolder, CancellationToken.None, TaskContinuationOptions.RunContinuationsAsynchronously, TaskScheduler.FromCurrentSynchronizationContext());
277277
#else
278278
task.ContinueWith(Complete, taskHolder, TaskScheduler.Current);
279279
#endif
@@ -350,7 +350,7 @@ public void ToJS<T>(Task<T>? value, ArgumentToJSCallback<T> marshaler)
350350
var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle);
351351

352352
#if FEATURE_WASM_MANAGED_THREADS
353-
task.ContinueWith(Complete, new HolderAndMarshaler<T>(taskHolder, marshaler), TaskScheduler.FromCurrentSynchronizationContext());
353+
task.ContinueWith(Complete, new HolderAndMarshaler<T>(taskHolder, marshaler), CancellationToken.None, TaskContinuationOptions.RunContinuationsAsynchronously, TaskScheduler.FromCurrentSynchronizationContext());
354354
#else
355355
task.ContinueWith(Complete, new HolderAndMarshaler<T>(taskHolder, marshaler), TaskScheduler.Current);
356356
#endif

0 commit comments

Comments
 (0)