示例#1
0
        public async Task RestartAsync()
        {
            if (Player == null || !Player.IsConnected || NowPlaying.Track.TrackString == null)
            {
                return;
            }

            await QueueLock.WaitAsync();

            QueueList.Insert(0, NowPlaying);
            await Player.StopAsync();

            QueueLock.Release();
        }
        /// <summary>
        /// Add the element to the Queue
        /// </summary>
        /// <param name="elem">Element to be added</param>
        public void Enqueue(T elem)  // if next index to tail == head => Q is FULL
        {
            Contract.Assert(elem != null, "The element to insert was null");
            Contract.Assert(IsReadOnly == false, "The Circular queue is read only");

            int?newIndex = null;

            newIndex = _tail != null?NextIndex(_tail.Value) : NextIndex(null);

            _tail = newIndex;
            Contract.Assert(newIndex != null, "The new index was null");

            QueueList.Insert(newIndex.Value, elem);
            if (_head == null)
            {
                _head = newIndex;
            }
        }
示例#3
0
        /// <summary>
        /// Enqueues a queue ticket to the queue list with priority considerations
        /// </summary>
        /// <param name="newTicket"></param>
        public void EnqueueTicket(QueueTicket newTicket)
        {
            if (QueueList.Count < QueueLane.Capacity &&
                newTicket.QueueLane.LaneID == newTicket.QueueLane.LaneID)
            {
                int indexToInsert = QueueList.FindIndex(
                    item => item.HasHigherPriority(
                        newTicket.PriorityNumber,
                        newTicket.QueueDateTime,
                        Tolerance
                        ));

                if (indexToInsert != -1)
                {
                    QueueList.Insert(indexToInsert, newTicket);
                }
                else
                {
                    //index at end of list
                    QueueList.Add(newTicket);
                }
            }
        }
 public void EnqueueSomeoneInTheRoom(int timeMinutes)
 {
     QueueList.Insert(0, new QueueSlot(0, timeMinutes));
     //throw new NotImplementedException();
 }