Skip to content

Commit e1028d5

Browse files
Copilotjkotas
andcommitted
Fix unsafe context compilation error in Thread.Interrupt
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
1 parent 1b99ad1 commit e1028d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,11 @@ public void Interrupt()
481481
SafeWaitHandle osHandle = _osHandle;
482482
if (osHandle != null && !osHandle.IsInvalid && !osHandle.IsClosed)
483483
{
484-
nint callbackPtr = (nint)(delegate* unmanaged<nint, void>)&InterruptApcCallback;
484+
nint callbackPtr;
485+
unsafe
486+
{
487+
callbackPtr = (nint)(delegate* unmanaged<nint, void>)&InterruptApcCallback;
488+
}
485489
Interop.Kernel32.QueueUserAPC(callbackPtr, osHandle.DangerousGetHandle(), IntPtr.Zero);
486490
}
487491
}

0 commit comments

Comments
 (0)