public void Add(T item) { lock (m_syncRoot) { m_list.Add(item); } ItemAdded.Fire(this, item); }
public void Insert(int index, T item) { lock (m_syncRoot) { m_list.Insert(index, item); } ItemAdded.Fire(this, item); }
public void Enqueue(T item) { lock (m_syncRoot) { m_queue.Enqueue(item); m_are.Set(); } ItemAdded.Fire(this, item); }
/// <summary> /// Adds an element to the head of the buffer /// </summary> /// <param name="item"></param> /// <remarks> /// If the buffer is full and Enqueue is called, the new item will be successfully added to the buffer and the tail (oldest) item will be automatically removed /// </remarks> public void Enqueue(T item) { lock (m_syncRoot) { if (IsFull) { // drop the tail item IncrementTail(); // notify the consumer OnOverrun(); } // put the new item in the list m_list[m_head] = item; IncrementHead(); if ((HighWaterLevel > 0) && (Count >= HighWaterLevel)) { if (!m_highwaterExceeded) { m_highwaterExceeded = true; HighWater.Fire(this, EventArgs.Empty); } } if ((LowWaterLevel > 0) && (Count > LowWaterLevel)) { m_lowwaterExceeded = false; } // do notifications m_addedResetEvent.Set(); ItemAdded.Fire(this, EventArgs.Empty); } }