/// <summary>
        /// Move the next object in the queue to inventory.  Then delete it properly from the scene.
        /// </summary>
        /// <returns></returns>
        public bool InventoryDeQueueAndDelete()
        {
            DeleteToInventoryHolder x = null;

            try
            {
                int left = m_inventoryDeletes.Count;
                if (left > 0)
                {
                    x = m_inventoryDeletes.Dequeue();

//                        m_log.DebugFormat(
//                            "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.",
//                            left, x.action, x.objectGroups.Count);

                    try
                    {
                        IInventoryAccessModule invAccess = m_scene.RequestModuleInterface <IInventoryAccessModule>();
                        if (invAccess != null)
                        {
                            invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient, false);
                        }

                        if (x.permissionToDelete)
                        {
                            foreach (SceneObjectGroup g in x.objectGroups)
                            {
                                m_scene.DeleteSceneObject(g, true);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat(
                            "[ASYNC DELETER]: Exception background sending object: {0}{1}", e.Message, e.StackTrace);
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                // We can't put the object group details in here since the root part may have disappeared (which is where these sit).
                // FIXME: This needs to be fixed.
                m_log.ErrorFormat(
                    "[ASYNC DELETER]: Queued sending of scene object to agent {0} {1} failed: {2} {3}",
                    (x != null ? x.remoteClient.Name : "unavailable"),
                    (x != null ? x.remoteClient.AgentId.ToString() : "unavailable"),
                    e.Message,
                    e.StackTrace);
            }

//            m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue.");

            return(false);
        }
        /// <summary>
        /// Process the queue of fetches
        /// </summary>
        protected void ProcessQueue()
        {
            FetchHolder fh = null;

            while (true)
            {
//                    m_log.DebugFormat("[ASYNC INVENTORY SENDER]: {0} items left to process", m_fetchHolder.Count);

                if (m_fetchHolder.Count == 0)
                {
                    m_processing = false;
                    return;
                }
                else
                {
                    fh = m_fetchHolder.Dequeue();
                }

                if (!fh.Client.IsActive)
                {
                    continue;
                }

//                m_log.DebugFormat(
//                    "[ASYNC INVENTORY SENDER]: Handling request from {0} for {1} on queue", fh.Client.Name, fh.ItemID);

                InventoryItemBase item = new InventoryItemBase(fh.ItemID, fh.Client.AgentId);
                item = m_scene.InventoryService.GetItem(item);

                if (item != null)
                {
                    fh.Client.SendInventoryItemDetails(item.Owner, item);
                }

                // TODO: Possibly log any failure
            }
        }
 /// <summary>
 /// Pop the first availlable listen event from the queue
 /// </summary>
 /// <returns>ListenerInfo with filter filled in</returns>
 public IWorldCommListenerInfo GetNextMessage()
 {
     return(m_pending.Dequeue());
 }