Esempio n. 1
0
        /// <summary>
        /// Gets the next availlable bagage on the ingoing buffers
        /// </summary>
        /// <returns></returns>
        private Bagage GetNextBagage()
        {
            for (int i = 0; i < InGoingBuffers.Length; i++)
            {
                CounterDesk curBuffer = InGoingBuffers[i];

                Monitor.Enter(curBuffer.Buffer.Lock);

                try
                {
                    if (curBuffer.Buffer.IsBufferEmpty)
                    {
                        Monitor.PulseAll(curBuffer.Buffer.Lock);
                        continue;
                    }

                    Bagage curBagage = curBuffer.Buffer.RemoveFromBackBuffer();
                    InGoingBagageHandler?.Invoke(curBagage);

                    return(curBagage);
                }
                finally
                {
                    Monitor.Exit(curBuffer.Buffer.Lock);
                }
            }

            return(null);
        }