예제 #1
0
        public void ReadWriteTest()
        {
            var collection = new PropertyCollectionClass();

            for (long i = 0; i < 100; i++)
            {
                AddRemoveItems(collection);
            }
        }
예제 #2
0
        public void ThreadingTests()
        {
            var collection = new PropertyCollectionClass();

            // create threads accessing the collection

            for (int i = 0; i < 100; i++)
            {
                Interlocked.Increment(ref _counter);
                new Thread(AddRemoveItems).Start(collection);
            }

            // wait for all threads to finish
            while (_counter > 0)
            {
                Thread.Sleep(1);
                Interlocked.MemoryBarrier();
            }

            // done
            Assert.AreEqual(0, collection.Count);
        }