/// <summary>
            /// Gets the proxy.
            /// </summary>
            /// <returns></returns>
            private IVisualRxServiceAdapterAsync GetProxy(ChannelFactory <IVisualRxServiceAdapterAsync> factory)
            {
                #region Validation

                if (factory.State == CommunicationState.Opening)
                {
                    SpinWait.SpinUntil(() => _factory.State != CommunicationState.Opening, 1000);
                }
                if (factory.State != CommunicationState.Opened)
                {
                    if (factory.State != CommunicationState.Closed &&
                        factory.State != CommunicationState.Closing)
                    {
                        try
                        {
                            factory.Abort();
                        }
                        catch { }
                    }

                    factory     = new ChannelFactory <IVisualRxServiceAdapterAsync>(_binding, _address);
                    _proxyCache = factory.CreateChannel();
                    _factory    = factory;
                }

                #endregion // Validation

                return(_proxyCache);
            }
            /// <summary>
            /// Gets the proxy.
            /// </summary>
            /// <returns></returns>
            private IVisualRxServiceAdapterAsync GetProxy(ChannelFactory <IVisualRxServiceAdapterAsync> factory)
            {
                // The sending is synchronized at the infrastructure level
                // therefore this class shouldn't be thread-safe

                #region Validation

                if (factory != null && factory.State == CommunicationState.Opening)
                {
                    SpinWait.SpinUntil(() => _factory.State != CommunicationState.Opening, 1000);
                }
                if (factory == null || factory.State != CommunicationState.Opened)
                {
                    if (factory != null &&
                        factory.State != CommunicationState.Closed &&
                        factory.State != CommunicationState.Closing)
                    {
                        try
                        {
                            factory.Abort();
                        }
                        catch { }
                    }

                    if (_lastChannelRecovery.Add(_channelRecoveryThrottling) > DateTime.UtcNow)
                    {
                        return(null);
                    }

                    TraceSourceMonitorHelper.Debug("Recovering channel for [{0}]", _address.Uri);

                    factory     = new ChannelFactory <IVisualRxServiceAdapterAsync>(_binding, _address);
                    _proxyCache = factory.CreateChannel();
                    _factory    = factory;

                    _lastChannelRecovery = DateTime.UtcNow;
                }

                #endregion // Validation

                return(_proxyCache);
            }