Пример #1
0
        private void Perform(IRestRequest request)
        {
            DateTime       start   = DateTime.UtcNow;
            IRestClient    client  = network.RestClient;
            AutoResetEvent signal  = new AutoResetEvent(false);
            RequestItem    pending = network.ProfilePending(request, start);

            try
            {
                asyncHandle = client.ExecuteAsync(request, response =>
                {
                    EndProfile(pending, response, signal);
                });
            }
            catch (Exception fault)             // sometimes requests just fail.
            {
                IRestResponse response = new FaultedRestResponse(request, fault);
                EndProfile(pending, response, signal);
            }
            int timeout = network.RestClient.Timeout;

            signal.WaitOne(timeout == 0 ? -1 : timeout);             // 0 and -1 indicate infinity in RestClient and EventWaitHandle respectively.
        }
Пример #2
0
        private void Perform(IRestRequest request)
        {
            DateTime start = DateTime.UtcNow;
            IRestClient client = network.RestClient;
            AutoResetEvent signal = new AutoResetEvent(false);
            RequestItem pending = network.ProfilePending(request, start);

            try
            {
                asyncHandle = client.ExecuteAsync(request, response =>
                {
                    EndProfile(pending, response, signal);
                });
            }
            catch (Exception fault) // sometimes requests just fail.
            {
                IRestResponse response = new FaultedRestResponse(request, fault);
                EndProfile(pending, response, signal);
            }
            int timeout = network.RestClient.Timeout;
            signal.WaitOne(timeout == 0 ? -1 : timeout); // 0 and -1 indicate infinity in RestClient and EventWaitHandle respectively.
        }