public List<GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID, GroupRolesListDelegate d)
        {
            object roles = null;
            bool firstCall = false;
            string cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();

            //m_log.DebugFormat("[XXX]: GetAgentGroupRoles {0}", cacheKey);

            while (true)
            {
                lock (m_Cache)
                {
                    if (m_Cache.TryGetValue(cacheKey, out roles))
                    {
                        //m_log.DebugFormat("[XXX]: GetAgentGroupRoles {0} cached!", cacheKey);
                        return (List<GroupRolesData>)roles;
                    }

                    // not cached
                    if (!m_ActiveRequests.ContainsKey(cacheKey))
                    {
                        m_ActiveRequests.Add(cacheKey, true);
                        firstCall = true;
                    }
                }

                if (firstCall)
                {
                    try
                    {
                        roles = d();
                        lock (m_Cache)
                        {
                            m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT);
                            m_ActiveRequests.Remove(cacheKey);
                            return (List<GroupRolesData>)roles;
                        }
                    }
                    finally
                    {
                        m_ActiveRequests.Remove(cacheKey);
                    }
                }
                else
                    Thread.Sleep(50);
            }
        }
        public List <GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID, GroupRolesListDelegate d)
        {
            object roles     = null;
            bool   firstCall = false;
            string cacheKey  = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();

            //m_log.DebugFormat("[XXX]: GetAgentGroupRoles {0}", cacheKey);

            while (true)
            {
                lock (m_Cache)
                {
                    if (m_Cache.TryGetValue(cacheKey, out roles))
                    {
                        //m_log.DebugFormat("[XXX]: GetAgentGroupRoles {0} cached!", cacheKey);
                        return((List <GroupRolesData>)roles);
                    }

                    // not cached
                    if (!m_ActiveRequests.Contains(cacheKey))
                    {
                        m_ActiveRequests.Add(cacheKey);
                        firstCall = true;
                    }
                }

                if (firstCall)
                {
                    try
                    {
                        roles = d();
                        m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT);
                        return((List <GroupRolesData>)roles);
                    }
                    finally
                    {
                        m_ActiveRequests.Remove(cacheKey);
                    }
                }
                else
                {
                    Thread.Sleep(50);
                }
            }
        }
        public List <GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID, GroupRolesListDelegate d)
        {
            object roles     = null;
            bool   firstCall = false;
            string cacheKey  = "roles-" + GroupID.ToString();

            while (true)
            {
                lock (m_Cache)
                {
                    if (m_Cache.TryGetValue(cacheKey, out roles))
                    {
                        return((List <GroupRolesData>)roles);
                    }

                    // not cached
                    if (!m_ActiveRequests.ContainsKey(cacheKey))
                    {
                        m_ActiveRequests.Add(cacheKey, true);
                        firstCall = true;
                    }
                }

                if (firstCall)
                {
                    roles = d();
                    if (roles != null)
                    {
                        lock (m_Cache)
                        {
                            m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT);
                            m_ActiveRequests.Remove(cacheKey);
                            return((List <GroupRolesData>)roles);
                        }
                    }
                }
                else
                {
                    Thread.Sleep(50);
                }
            }
        }
        public List<GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID, GroupRolesListDelegate d)
        {
            object roles = null;
            bool firstCall = false;
            string cacheKey = "roles-" + GroupID.ToString();

            while (true)
            {
                lock (m_Cache)
                {
                    if (m_Cache.TryGetValue(cacheKey, out roles))
                        return (List<GroupRolesData>)roles;

                    // not cached
                    if (!m_ActiveRequests.ContainsKey(cacheKey))
                    {
                        m_ActiveRequests.Add(cacheKey, true);
                        firstCall = true;
                    }
                }

                if (firstCall)
                {
                    roles = d();
                    if (roles != null)
                    {
                        lock (m_Cache)
                        {
                            m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT);
                            m_ActiveRequests.Remove(cacheKey);
                            return (List<GroupRolesData>)roles;
                        }
                    }
                }
                else
                    Thread.Sleep(50);
            }
        }