Example #1
0
        public void ConcurrentAddAndTestTest()
        {
            int size = 1000;
            int[] correct = new int[size];

            var queue = new WaitQueue<int>();
            ThreadPool.QueueUserWorkItem(
                x =>
                {
                    foreach (var i in Range(size).AsParallel())
                    {
                        queue.Add(i);
                    }
                });

            foreach (var i in Range(size).AsParallel())
            {
                var result = queue.Take();
                correct[result]++;
            }
            foreach (var i in Range(size))
            {
                Assert.AreEqual(1, correct[i], "Invalid value at" + i + " = " + correct[i]);
            }
        }
Example #2
0
        public void ConcurrentAddAndTestTest()
        {
            int size = 1000;

            int[] correct = new int[size];

            var queue = new WaitQueue <int>();

            ThreadPool.QueueUserWorkItem(
                x =>
            {
                foreach (var i in Range(size).AsParallel())
                {
                    queue.Add(i);
                }
            });

            foreach (var i in Range(size).AsParallel())
            {
                var result = queue.Take();
                correct[result]++;
            }
            foreach (var i in Range(size))
            {
                Assert.AreEqual(1, correct[i], "Invalid value at" + i + " = " + correct[i]);
            }
        }
Example #3
0
 public void Schedule(Action action)
 {
     _actions.Add(action);
     //return scheduledAction;
 }