/// <summary>
        /// Retrieves the next pending command from this connection's command queue.
        /// </summary>
        /// <returns>
        /// The next pending command, or null if there are none.
        /// </returns>
        internal BTCmd GetNextCommand()
        {
            if (m_commandQueue.Count == 0)
            {
                return(null);
            }

            BTCmd next = null;

            lock (m_commandQueue)
            {
                next = (BTCmd)m_commandQueue[0];

                m_commandQueue.RemoveAt(0);
            }

            return(next);
        }
 /// <summary>
 /// Callback from the BTManager that indicates a command has been completed.
 /// </summary>
 /// <param name="cmd">
 /// The completed command; describes the command and its result
 /// </param>
 /// <param name="error">
 /// Whether or not the command resulted in an error.
 /// </param>
 internal void CmdCompletedCallback(BTCmd cmd, bool error)
 {
     m_cmdComplete(this, cmd, error);
 }
        /// <summary>
        /// Queues a list of BTCmd objects and tells the BTManager to schedule and
        /// dispatch them.
        /// </summary>
        /// <param name="cmds">
        /// The list of BTCmd objects
        /// </param>
        public void QueueCommands(BTCmd[] cmds)
        {
            if (m_disposed) throw new InvalidOperationException("BTConnection has been disposed");

            lock (m_commandQueue)
            {
                for (int i = 0; i < cmds.Length; ++i) m_commandQueue.Add(cmds[i]);
            }

            m_manager.OnNewCommand(this);
        }
 /// <summary>
 /// Callback from the BTManager that indicates a command has been completed.
 /// </summary>
 /// <param name="cmd">
 /// The completed command; describes the command and its result
 /// </param>
 /// <param name="error">
 /// Whether or not the command resulted in an error.
 /// </param>
 internal void CmdCompletedCallback(BTCmd cmd, bool error)
 {
     m_cmdComplete(this, cmd, error);
 }