static void Main(string[] args)
        {
            WorkQueue        workQueue     = new WorkQueue(new ConcurrentQueue <WorkTask>());
            WorkItemProducer producerOne   = new WorkItemProducer(workQueue);
            WorkItemProducer producerTwo   = new WorkItemProducer(workQueue);
            WorkItemProducer producerThree = new WorkItemProducer(workQueue);

            Task producerTaskOne   = Task.Run(() => producerOne.ProduceWorkItems());
            Task producerTaskTwo   = Task.Run(() => producerTwo.ProduceWorkItems());
            Task producerTaskThree = Task.Run(() => producerThree.ProduceWorkItems());
            Task consumerTaskOne   = Task.Run(() => workQueue.MonitorWorkQueue());
            Task consumerTaskTwo   = Task.Run(() => workQueue.MonitorWorkQueue());

            Task.WaitAll(producerTaskOne, producerTaskThree, producerTaskTwo);
            workQueue.AllItemsAdded();
            Task.WaitAll(consumerTaskOne, consumerTaskTwo);
            Console.WriteLine("Tasks finished...");
            Console.ReadKey();
        }
        public void RunBlockingCollectionCodeSample()
        {
            Console.WriteLine("Tasks started...");

            DateTime start = DateTime.Now;

            WorkQueue workQueue = new WorkQueue(new ConcurrentQueue<WorkTask>());
            WorkItemProducer producerOne = new WorkItemProducer(workQueue);

            Task producerTaskOne = Task.Run(() => producerOne.ProduceWorkItems());

            Task[] taskConsumerArray = new Task[5];
            for(int i =0; i < taskConsumerArray.Length; i++)
            {
                taskConsumerArray[i] = Task.Run(() => workQueue.MonitorWorkQueue());
            }
            Task.WaitAll(producerTaskOne);
            workQueue.AllItemsAdded();
            Console.WriteLine("added all");
            Task.WaitAll(taskConsumerArray);
            Console.WriteLine("Tasks are finished...");
            Console.WriteLine(string.Format("Finished in {0} seconds", (DateTime.Now - start).TotalSeconds));
        }