Exemple #1
0
        /// <summary>
        /// Enqueues the list of items
        /// </summary>
        /// <param name="ItemsToQueue">list of items to enqueue</param>
        public void EnqueueAll(ListThreadSafe <T> ItemsToQueue)
        {
            LockQ.EnterWriteLock();
            try
            {
                // loop through and add each item
                foreach (T item in ItemsToQueue)
                {
                    m_Queue.Enqueue(item);
                }
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }
Exemple #2
0
        // EnqueueAll
        #endregion

        #region DequeueAll

        /// <summary>
        /// Dequeues all the items and returns them as a thread safe list
        /// </summary>
        public ListThreadSafe <T> DequeueAll()
        {
            LockQ.EnterWriteLock();
            try
            {
                // create return object
                ListThreadSafe <T> returnList = new ListThreadSafe <T>();

                // dequeue until everything is out
                while (m_Queue.Count > 0)
                {
                    returnList.Add(m_Queue.Dequeue());
                }

                // return the list
                return(returnList);
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }