public void Shutdown()
 {
     _active.Set(false);
     lock (_lifecycleLock)
     {
         FireLifecycleEvent(LifecycleEvent.LifecycleState.ShuttingDown);
         _client.DoShutdown();
         FireLifecycleEvent(LifecycleEvent.LifecycleState.Shutdown);
     }
 }
 private void DoShutdown()
 {
     lock (_shutdownLock)
     {
         if (!_active.CompareAndSet(true, false))
         {
             return;
         }
         FireLifecycleEvent(LifecycleEvent.LifecycleState.ShuttingDown);
         _client.DoShutdown();
         FireLifecycleEvent(LifecycleEvent.LifecycleState.Shutdown);
     }
 }