public static void SafeWaitHandle()
 {
     var eventWaitHandle = new ManualResetEvent(false);
     var eventSafeWaitHandle = eventWaitHandle.SafeWaitHandle;
     var testWaitHandle = new TestWaitHandle();
     testWaitHandle.SafeWaitHandle = eventSafeWaitHandle;
     Assert.False(testWaitHandle.WaitOne(0));
     eventWaitHandle.Set();
     Assert.True(testWaitHandle.WaitOne(0));
     testWaitHandle.SafeWaitHandle = null;
     Assert.Throws<ObjectDisposedException>(() => testWaitHandle.WaitOne(0));
 }
        public void SafeWaitHandle()
        {
            var eventWaitHandle     = new ManualResetEvent(false);
            var eventSafeWaitHandle = eventWaitHandle.SafeWaitHandle;
            var testWaitHandle      = new TestWaitHandle();

            testWaitHandle.SafeWaitHandle = eventSafeWaitHandle;
            Assert.IsFalse(testWaitHandle.WaitOne(0));
            eventWaitHandle.Set();
            Assert.IsTrue(testWaitHandle.WaitOne(0));
            testWaitHandle.SafeWaitHandle = null;
            AssertExtensions.Throws <ObjectDisposedException>(() => testWaitHandle.WaitOne(0));
        }
Ejemplo n.º 3
0
        public static void SafeWaitHandleViaExtension()
        {
            ManualResetEvent eventWaitHandle     = new ManualResetEvent(false);
            SafeWaitHandle   eventSafeWaitHandle = eventWaitHandle.GetSafeWaitHandle();
            TestWaitHandle   testWaitHandle      = new TestWaitHandle();

            testWaitHandle.SetSafeWaitHandle(eventSafeWaitHandle);
            Assert.False(testWaitHandle.WaitOne(0));
            eventWaitHandle.Set();
            Assert.True(testWaitHandle.WaitOne(0));
            testWaitHandle.SetSafeWaitHandle(null);
            Assert.Throws <ObjectDisposedException>(() => testWaitHandle.WaitOne(0));
        }
Ejemplo n.º 4
0
        public static void Handle()
        {
            var eventWaitHandle    = new ManualResetEvent(false);
            var eventRawWaitHandle = eventWaitHandle.Handle;
            var testWaitHandle     = new TestWaitHandle();

            testWaitHandle.Handle = eventRawWaitHandle;
            Assert.False(testWaitHandle.WaitOne(0));
            eventWaitHandle.Set();
            Assert.True(testWaitHandle.WaitOne(0));
            testWaitHandle.ClearHandle();
            Assert.Throws <ObjectDisposedException>(() => testWaitHandle.WaitOne(0));
        }