/// <summary> /// Pops all events, emptying the queue. /// </summary> /// <returns></returns> public IEvent[] PopAll() { lock (this) { IEvent[] eventArray = new IEvent[events.Count]; events.CopyTo(eventArray, 0); events.Clear(); return eventArray; } }
/// <summary> /// Pushes a new event onto the event queue, meaning it falls on the end of the stack. /// This will be later processed through Pop(). /// </summary> /// <param name="eventToBuffer"></param> /// <exception cref="System.ArgumentNullException"></exception> public void Push(IEvent eventToBuffer) { if (eventToBuffer == null) { throw new ArgumentNullException("Argument 'eventToBuffer' may not be null."); } lock (this) { events.Enqueue(eventToBuffer); } }