public void CanEnqueueAndDequeue() { _queue.TryEnqueue(1); _queue.TryEnqueue(2); _queue.TryEnqueue(3); object actual; _queue.TryDequeue(out actual); Assert.Equal(1, actual); _queue.TryDequeue(out actual); Assert.Equal(2, actual); _queue.TryDequeue(out actual); Assert.Equal(3, actual); }
public void Dequeue() { for (var i = 0; i < Operations; i++) { object item; _queue.TryDequeue(out item); } }
public void EnqueueDequeue() { _queue.TryEnqueue(_obj); object ret; _queue.TryDequeue(out ret); }
private Thread[] LaunchConsumers(int numberOfThreads) { var threads = new Thread[numberOfThreads]; for (var i = 0; i < numberOfThreads; i++) { var thread = new Thread(() => { var isWorking = true; while (isWorking) { object ret; if (_queue.TryDequeue(out ret)) { isWorking = ((Message)ret).IsWorking; } } }); thread.Start(); threads[i] = thread; } return(threads); }