static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);


            Producer prod  = new Producer(buf, 100);
            Consumer cons1 = new Consumer(buf);
            Consumer cons2 = new Consumer(buf);

            //MiddleMan mid = new MiddleMan(,);

            Parallel.Invoke(prod.Run, cons1.Run, cons2.Run /*, mid.Run*/);


            Console.ReadKey();
            Console.WriteLine("DONE!\nThe buffer was filled {0} times", BoundedBuffer._bug);
            Console.ReadKey();

            //Parallel.Invoke(
            //   () => Console.Write("Hej"),
            //   () => Console.Write("Hello"));
        }
Exemple #2
0
 public Consumer(BoundedBuffer buffer)
 {
     this._buffer = buffer;
 }
 public Producer(BoundedBuffer buffer, int howManyToProduce)
 {
     this._max    = howManyToProduce;
     this._buffer = buffer;
 }
 public MiddleMan(BoundedBuffer bufferIn, BoundedBuffer bufferOut)
 {
     this._bufferIn  = bufferIn;
     this._bufferOut = bufferOut;
 }