public void TestAcquireInterruptibly2() { Mutex sync = new Mutex(); try { sync.AcquireInterruptibly(1); } catch (Exception e) { UnexpectedException(e); } Thread t = new Thread(InterruptedSyncRunnable); try { t.Start(sync); t.Interrupt(); Assert.IsTrue(sync.AccessIsHeldExclusively()); t.Join(); } catch (Exception e) { UnexpectedException(e); } }
private void InterruptibleSyncRunnable(Object state) { try { Mutex sync = state as Mutex; sync.AcquireInterruptibly(1); } catch (ThreadInterruptedException) { } catch (Exception e) { ThreadUnexpectedException(e); } }
private void InterruptedSyncRunnable(Object state) { try { Mutex sync = state as Mutex; sync.AcquireInterruptibly(1); ThreadShouldThrow("InterruptedSyncRunnable should have been interrupted in Acquire"); } catch (ThreadInterruptedException) { } catch (Exception e) { ThreadUnexpectedException(e); } }