public void RefreshServerStatistics()
        {
            if (_isRefreshing == true)
                return;

            // It's not the end of the world if a call makes it through on a race condition.
            // We're just going to try to stop it from spamming the cache servers if one of
            // them takes longer than 5 seconds to respond.
            //lock (_syncLock)
            //{
                _isRefreshing = true;

                try
                {
                    for(int serverIndex = 0; serverIndex < _serversToMonitor.Count; serverIndex++)
                    {
                        Server server = _serversToMonitor[serverIndex];

                        if (_stopRequested == true)
                            break;

                        //foreach (Instance instance in server.Instances)
                        for(int instanceIndex = 0; instanceIndex < server.Instances.Count; instanceIndex++)
                        {
                            Instance instance = server.Instances[instanceIndex];

                            if (_stopRequested == true)
                                break;

                            MemcachedClient memcachedClient;
                            System.Net.IPEndPoint serverEndPoint = new System.Net.IPEndPoint(System.Net.Dns.GetHostEntry(server.ServerName).AddressList[0], instance.TcpPort);

                            if (_memcachedConnections.ContainsKey(instance) == false)
                            {
                                MemcachedClientConfiguration config = new MemcachedClientConfiguration();
                                config.Servers.Add(serverEndPoint);
                                config.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 3);

                                //config.SocketPool.

                                memcachedClient = new MemcachedClient(config);

                                _memcachedConnections.Add(instance, memcachedClient);
                            }
                            else
                            {
                                memcachedClient = _memcachedConnections[instance];
                            }

                            State serviceState = State.Unknown;

                            try
                            {
                                serviceState = instance.GetServiceState(server);
                            }
                            catch (Exception ex)
                            {
                                // Leave the state as unknown.
                                Debug.WriteLine(ex);
                            }

                            ServerStats serverStats = memcachedClient.Stats();
                            InstanceStatistics instanceStatistics = new InstanceStatistics(serverEndPoint, server, instance, serverStats, serviceState);

                            if (InstanceUpdated != null)
                                InstanceUpdated(server, instance, instanceStatistics);
                        }
                    }
                }
                finally
                {
                    _isRefreshing = false;
                }
            //}
        }
        public void RefreshServerStatistics()
        {
            if (_isRefreshing == true)
            {
                return;
            }

            // It's not the end of the world if a call makes it through on a race condition.
            // We're just going to try to stop it from spamming the cache servers if one of
            // them takes longer than 5 seconds to respond.
            //lock (_syncLock)
            //{
            _isRefreshing = true;

            try
            {
                for (int serverIndex = 0; serverIndex < _serversToMonitor.Count; serverIndex++)
                {
                    Server server = _serversToMonitor[serverIndex];

                    if (_stopRequested == true)
                    {
                        break;
                    }

                    //foreach (Instance instance in server.Instances)
                    for (int instanceIndex = 0; instanceIndex < server.Instances.Count; instanceIndex++)
                    {
                        Instance instance = server.Instances[instanceIndex];

                        if (_stopRequested == true)
                        {
                            break;
                        }

                        MemcachedClient       memcachedClient;
                        System.Net.IPEndPoint serverEndPoint = new System.Net.IPEndPoint(System.Net.Dns.GetHostEntry(server.ServerName).AddressList[0], instance.TcpPort);

                        if (_memcachedConnections.ContainsKey(instance) == false)
                        {
                            MemcachedClientConfiguration config = new MemcachedClientConfiguration();
                            config.Servers.Add(serverEndPoint);
                            config.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 3);

                            //config.SocketPool.

                            memcachedClient = new MemcachedClient(config);

                            _memcachedConnections.Add(instance, memcachedClient);
                        }
                        else
                        {
                            memcachedClient = _memcachedConnections[instance];
                        }

                        State serviceState = State.Unknown;

                        try
                        {
                            serviceState = instance.GetServiceState(server);
                        }
                        catch (Exception ex)
                        {
                            // Leave the state as unknown.
                            Debug.WriteLine(ex);
                        }

                        ServerStats        serverStats        = memcachedClient.Stats();
                        InstanceStatistics instanceStatistics = new InstanceStatistics(serverEndPoint, server, instance, serverStats, serviceState);

                        if (InstanceUpdated != null)
                        {
                            InstanceUpdated(server, instance, instanceStatistics);
                        }
                    }
                }
            }
            finally
            {
                _isRefreshing = false;
            }
            //}
        }