예제 #1
0
        public void TestInvalidOrder2()
        {
            // T1 locks obj1
            // T2 locks obj2
            // T3 locks obj3

            var lockObj1 = TracedLock.Register("TestInvalidOrder2.lockObj1");
            var lockObj2 = TracedLock.Register("TestInvalidOrder2.lockObj2");
            var lockObj3 = TracedLock.Register("TestInvalidOrder2.lockObj3");

            int value = 0;

            using (TracedLock.Lock(lockObj2))
                using (TracedLock.Lock(lockObj3))
                {
                    value++;
                }

            using (TracedLock.Lock(lockObj1))
                using (TracedLock.Lock(lockObj2))
                {
                    value++;
                }

            using (TracedLock.Lock(lockObj3))
                using (TracedLock.Lock(lockObj1))         // <- I expect some "possible deadlock" detection here
                {
                    value++;
                }
        }
예제 #2
0
        public void TestValidOrderMixing1()
        {
            var lockObj1 = TracedLock.Register("TestValidOrderMixing1.lockObj1");
            var lockObj2 = TracedLock.Register("TestValidOrderMixing1.lockObj2");
            var lockObj3 = TracedLock.Register("TestValidOrderMixing1.lockObj3");

            int value = 0;

            using (TracedLock.Lock(lockObj1))
                using (TracedLock.Lock(lockObj2))
                {
                    value++;
                }

            using (TracedLock.Lock(lockObj1))
                using (TracedLock.Lock(lockObj3))
                {
                    value++;
                }

            using (TracedLock.Lock(lockObj2))
                using (TracedLock.Lock(lockObj3))
                {
                    value++;
                }

            var orders = LockAnalyzer.DeadlockOrders;
        }