void Cleanup(TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
            Exception     exception     = null;

            lock (this.thisLock)
            {
                this.discoveryCompleted = true;
            }

            try
            {
                this.discoveryClient.CancelAsync(this);
                ((ICommunicationObject)this.discoveryClient).Close(timeoutHelper.RemainingTime());
            }
            catch (TimeoutException timeoutException)
            {
                exception = timeoutException;
            }
            catch (CommunicationException communicationException)
            {
                exception = communicationException;
            }
            finally
            {
                if (exception != null && TD.DiscoveryClientInClientChannelFailedToCloseIsEnabled())
                {
                    TD.DiscoveryClientInClientChannelFailedToClose(exception);
                }
            }

            this.discoveredEndpoints.Dispose();

            this.discoveryClient           = null;
            this.discoveredEndpoints       = null;
            this.findCriteria              = null;
            this.discoveryEndpointProvider = null;
            this.innerChannelFactory       = null;
        }