示例#1
0
        /// <summary>
        /// Enqueues a new event onto the event queue, meaning it falls on the end of the stack.
        /// This will be later processed through Dequeue().
        /// </summary>
        /// <param name="eventToBuffer"></param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public void Enqueue(IEvent eventToBuffer)
        {
            if (eventToBuffer == null)
            {
                throw new ArgumentNullException("Argument 'eventToBuffer' may not be null.");
            }

            lock (this)
            {
                events.Enqueue(eventToBuffer);
            }
        }
示例#2
0
        /// <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;
            }
        }