Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Testing with unsafe counter");

            ICounter unsafeCounter = new UnsafeCounter();

            TestCounter(unsafeCounter);

            Console.WriteLine("Testing with safe counter (entire object threadsafed)");

            var safeCounter = unsafeCounter.ThreadSafeProxy();

            TestCounter(safeCounter);

            Console.WriteLine("Testing with safe counter (GetAndIncrement threadsafed)");

            safeCounter = unsafeCounter.ConfigureThreadSafeProxy().ForMember(counter => counter.GetAndIncrement()).Build();

            TestCounter(safeCounter);

            Console.WriteLine("Testing with safe counter (GetAndIncrement not threadsafed, should have problems...)");

            safeCounter = unsafeCounter.ConfigureThreadSafeProxy().Except().ForMember(counter => counter.GetAndIncrement()).Build();

            TestCounter(safeCounter);

            Console.WriteLine("Complete!  Press any key.");

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Testing with unsafe counter");

            ICounter unsafeCounter = new UnsafeCounter();

            TestCounter(unsafeCounter);

            Console.WriteLine("Testing with safe counter (entire object threadsafed)");

            var safeCounter = unsafeCounter.ThreadSafeProxy();

            TestCounter(safeCounter);

            Console.WriteLine("Testing with safe counter (GetAndIncrement threadsafed)");

            safeCounter = unsafeCounter.ConfigureThreadSafeProxy().ForMember(counter => counter.GetAndIncrement()).Build();

            TestCounter(safeCounter);

            Console.WriteLine("Testing with safe counter (GetAndIncrement not threadsafed, should have problems...)");

            safeCounter = unsafeCounter.ConfigureThreadSafeProxy().Except().ForMember(counter => counter.GetAndIncrement()).Build();

            TestCounter(safeCounter);

            Console.WriteLine("Complete!  Press any key.");

            Console.ReadKey();
        }