예제 #1
0
        /// <summary>
        /// Puts the bagage on the belt if the buffer is not full
        /// </summary>
        /// <param name="bagage"></param>
        private void PutBagageOnBelt(Bagage bagage)
        {
            Monitor.Enter(Buffer.Lock);

            try
            {
                if (Buffer.IsBufferFull)
                {
                    Monitor.Wait(Buffer.Lock);
                }

                Buffer.AddToFrontBuffer(bagage);

                if (Buffer.BufferCounter == 1)
                {
                    Monitor.PulseAll(Buffer.Lock);
                }
            }
            finally
            {
                Monitor.Exit(Buffer.Lock);
            }
        }