public void TestIsQueued() { Mutex sync = new Mutex(); Thread t1 = new Thread(InterruptedSyncRunnable); Thread t2 = new Thread(InterruptibleSyncRunnable); try { Assert.IsFalse(sync.IsQueued(t1)); Assert.IsFalse(sync.IsQueued(t2)); sync.Acquire(1); t1.Start(sync); Thread.Sleep(SHORT_DELAY_MS); Assert.IsTrue(sync.IsQueued(t1)); t2.Start(sync); Thread.Sleep(SHORT_DELAY_MS); Assert.IsTrue(sync.IsQueued(t1)); Assert.IsTrue(sync.IsQueued(t2)); t1.Interrupt(); Thread.Sleep(SHORT_DELAY_MS); Assert.IsFalse(sync.IsQueued(t1)); Assert.IsTrue(sync.IsQueued(t2)); sync.Release(1); Thread.Sleep(SHORT_DELAY_MS); Assert.IsFalse(sync.IsQueued(t1)); Thread.Sleep(SHORT_DELAY_MS); Assert.IsFalse(sync.IsQueued(t2)); t1.Join(); t2.Join(); } catch(Exception e) { UnexpectedException(e); } }
public void TestIsQueuedNPE() { Mutex sync = new Mutex(); try { sync.IsQueued(null); ShouldThrow(); } catch (NullReferenceException) { } }