Beispiel #1
0
        /// <summary>
        /// Enqueues a collection of items into the double-buffered queue.
        /// </summary>
        /// <param name="items">The collection of items to be enqueued.</param>
        public void Enqueue(IEnumerable<T> items)
        {
#if MONO
            lock (m_swapLock)
            {
#else
            bool lockTaken = false;

            try
            {
                m_swapLock.Enter(ref lockTaken);
#endif
                m_lists[m_listIndex].AddRange(items);
                m_count = m_lists[m_listIndex].Count;
            }
#if !MONO
            finally
            {
                if (lockTaken)
                    m_swapLock.Exit();
            }
#endif
            if ((object)ProcessItemsFunction != null)
                m_processItemsOperation.RunOnceAsync();
        }
Beispiel #2
0
        /// <summary>
        /// Enqueues an item for processing.
        /// </summary>
        /// <param name="item">Item to be queued for processing.</param>
        public void Enqueue(T item)
        {
            if ((object)m_processItemFunction == null)
            {
                throw new NullReferenceException("No item processing function has been assigned - cannot enqueue item for processing.");
            }

            // Queue item for processing
            if (Enabled)
            {
                m_asyncQueue.Enqueue(item);
                m_processItemOperation.RunOnceAsync();
            }
        }