FindResponse Find(FindCriteria criteria)
        {
            var req = new MessageContractsApril2005.FindRequest()
            {
                Body = new FindCriteriaApril2005(criteria)
            };

            Channel.BeginFind(req, delegate(IAsyncResult result) {
                Channel.EndFind(result);
            }, null);

            var timeout = InnerChannel.OperationTimeout < criteria.Duration ? InnerChannel.OperationTimeout : criteria.Duration;

            if (!reply_find_handle.WaitOne(timeout))
            {
                throw new EndpointNotFoundException("The discovery client could not receive Find operation response within the operation timeout.");
            }
            try {
                var ir  = find_completed();
                var ret = new FindResponse();
                foreach (var fr in ir.Body)
                {
                    ret.Endpoints.Add(fr.ToEndpointDiscoveryMetadata());
                }
                return(ret);
            } finally {
                find_completed = null;
            }
        }
        public IAsyncResult BeginFind(FindCriteria criteria, AsyncCallback callback, object state)
        {
            var req = new MessageContractsApril2005.FindRequest()
            {
                Body = new FindCriteriaApril2005(criteria)
            };

            return(Channel.BeginFind(req, callback, state));
        }