Example #1
0
        public void TestOneshotFlag()
        {
            var val = new AutoResetFlag(true);

            Assert.IsTrue(val.Peek());
            Assert.IsTrue(val.Read());
            Assert.IsTrue(!val.Peek());
            Assert.IsTrue(!val.Read());
            Assert.IsTrue(!val.Peek());
            val.Set();
            Assert.IsTrue(val.Peek());
            Assert.IsTrue(val.Read());
            Assert.IsTrue(!val.Peek());
            Assert.IsTrue(!val.Read());
            Assert.IsTrue(!val.Peek());

            val = new AutoResetFlag(false);
            Assert.IsTrue(!val.Peek());
            Assert.IsTrue(!val.Read());
            Assert.IsTrue(!val.Peek());
            val.Set();
            Assert.IsTrue(val.Peek());
            Assert.IsTrue(val.Read());
            Assert.IsTrue(!val.Peek());
            Assert.IsTrue(!val.Read());
            Assert.IsTrue(!val.Peek());
        }