private void Enable(LoadBalancerItemWrapper <ThriftEndpoint> wrappedThriftEndpoint)
 {
     lock (this)
     {
         wrappedThriftEndpoint.Enabled = true;
         enabledCount++;
     }
 }
 private void Disable(LoadBalancerItemWrapper <ThriftEndpoint> wrappedThriftEndpoint)
 {
     lock (this)
     {
         wrappedThriftEndpoint.Enabled = false;
         enabledCount--;
     }
 }
        private void StartMonitoring(LoadBalancerItemWrapper <ThriftEndpoint> wrappedThriftEndpoint)
        {
            var endpoint = wrappedThriftEndpoint.Item.Endpoint;
            var thread   = new Thread(() =>
            {
                for (;;)
                {
                    var socket = new TSocket(endpoint.Address.ToString(), endpoint.Port, PingSocketTimeout);
                    if (socket.TryOpen())
                    {
                        socket.Close();
                        Enable(wrappedThriftEndpoint);
                        RemovePingingThread(wrappedThriftEndpoint.Item);
                        return;
                    }

                    Thread.Sleep(PingSocketInterval * 1000);
                }
            });

            RegisterPingingThread(wrappedThriftEndpoint.Item, thread);
            thread.Start();
        }