See MonitorTests.InterruptWaitTest under src/libraries/System.Threading/tests (the test is being added by PR #87672):
|
public static void InterruptWaitTest() |
|
{ |
|
object obj = new(); |
|
lock (obj) |
|
{ |
|
var threadReady = new AutoResetEvent(false); |
|
var t = |
|
ThreadTestHelpers.CreateGuardedThread(out Action waitForThread, () => |
|
{ |
|
threadReady.Set(); |
|
Assert.Throws<ThreadInterruptedException>(() => Monitor.Enter(obj)); |
|
}); |
|
t.IsBackground = true; |
|
t.Start(); |
|
threadReady.CheckedWait(); |
|
t.Interrupt(); |
|
waitForThread(); |
|
} |
|
} |
See
MonitorTests.InterruptWaitTestundersrc/libraries/System.Threading/tests(the test is being added by PR #87672):runtime/src/libraries/System.Threading/tests/MonitorTests.cs
Lines 493 to 511 in ed64748