Exemplo n.º 1
0
        /// <summary>
        /// Clear a type of command in work queue
        /// </summary>
        public void Clear(WorkQueueElement.Command commandType)
        {
            lock (m_queue)
            {
                Queue<WorkQueueElement> tempQueue = new Queue<WorkQueueElement>();

                while (m_queue.Count > 0)
                {
                    WorkQueueElement elem = m_queue.Dequeue();
                    if (elem.CommandToPerform == commandType)
                    {
                        HLSTrace.WriteLine("Clear command {0}", elem.CommandToPerform.ToString());
                    }
                    else
                    {
                        tempQueue.Enqueue(elem);
                    }
                }

                while (tempQueue.Count > 0)
                {
                    m_queue.Enqueue(tempQueue.Dequeue());
                }

                if (m_queue.Count == 0)
                {
                    m_queueHasItemsEvent.Reset();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clear the queue and add 1 item in the same operation. This is useful
 /// for operation that take precedence over all others (like closing and errors)
 /// </summary>
 /// <param name="elem">New item to add</param>
 public void ClearAndEnqueue(WorkQueueElement elem)
 {
     lock (m_queue)
     {
         m_queue.Clear();
         m_queue.Enqueue(elem);
         m_queueHasItemsEvent.Set();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Enqueue a new work item
 /// </summary>
 /// <param name="elem">the item to add</param>
 public void Enqueue(WorkQueueElement elem)
 {
     lock (m_queue)
     {
         m_queue.Enqueue(elem);
         if (1 == m_queue.Count)
         {
             m_queueHasItemsEvent.Set();
         }
     }
 }