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]); } }
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]); } }
public void Schedule(Action action) { _actions.Add(action); //return scheduledAction; }