示例#1
0
        /// <summary>
        /// Thread-safe version of Queue.Enqueue(T).
        /// </summary>
        /// <param name="element">Object to enqueue.</param>
        public void Enqueue(T element)
        {
            bool wakeup = false;

            lock (_queueLock)
            {
                _queue.Enqueue(element);
                if (_queue.Count == 1)
                {
                    wakeup = true;
                }
            }
            if (wakeup && _node != null)
            {
                _node.WakeUp();
            }
        }