Example #1
0
        private void GetResponseCallbackHelper(object state)
        {
            IAsyncResult result = state as IAsyncResult;

            IAsyncExecutionContext         executionContext = null;
            IHttpRequest <TRequestContent> httpRequest      = null;

            try
            {
                executionContext = result.AsyncState as IAsyncExecutionContext;
                httpRequest      = executionContext.RuntimeState as IHttpRequest <TRequestContent>;

                var httpResponse = httpRequest.EndGetResponse(result);
                executionContext.ResponseContext.HttpResponse = httpResponse;
            }
            catch (Exception exception)
            {
                // Capture the exception and invoke outer handlers to
                // process the exception.
                executionContext.ResponseContext.AsyncResult.Exception = exception;
            }
            finally
            {
                executionContext.RequestContext.Metrics.StopEvent(Metric.HttpRequestTime);
                httpRequest.Dispose();
                base.InvokeAsyncCallback(executionContext);
            }
        }
Example #2
0
        private void ProcessPostResponse(IAsyncResult result)
        {
            IAsyncExecutionContext executionContext = null;
            IHttpRequest <string>  httpRequest      = null;

            try
            {
                executionContext = result.AsyncState as IAsyncExecutionContext;
                httpRequest      = executionContext.RuntimeState as IHttpRequest <string>;

                var httpResponse = httpRequest.EndGetResponse(result);
                executionContext.ResponseContext.HttpResponse = httpResponse;
            }
            catch (Exception exception)
            {
                // Capture the exception and invoke outer handlers to
                // process the exception.
                executionContext.ResponseContext.AsyncResult.Exception = exception;
            }
            finally
            {
                httpRequest.Dispose();
            }

            PostResponseHelper(result);
        }
Example #3
0
        private void GetResponseCallbackHelper(object state)
        {
            IAsyncResult                   asyncResult           = state as IAsyncResult;
            IAsyncExecutionContext         asyncExecutionContext = null;
            IHttpRequest <TRequestContent> httpRequest           = null;

            try
            {
                asyncExecutionContext = (asyncResult.AsyncState as IAsyncExecutionContext);
                httpRequest           = (asyncExecutionContext.RuntimeState as IHttpRequest <TRequestContent>);
                IWebResponseData httpResponse = httpRequest.EndGetResponse(asyncResult);
                asyncExecutionContext.ResponseContext.HttpResponse = httpResponse;
            }
            catch (Exception exception)
            {
                asyncExecutionContext.ResponseContext.AsyncResult.Exception = exception;
            }
            finally
            {
                asyncExecutionContext.RequestContext.Metrics.StopEvent(Metric.HttpRequestTime);
                httpRequest.Dispose();
                base.InvokeAsyncCallback(asyncExecutionContext);
            }
        }
Example #4
0
        private RestOperation PerformOperationAsync(string operationName, IProcessResponses responseProcessor, params object[] args)
        {
            JsonObject argsObject = null;

            if ((args != null) && (args.Length != 0))
            {
                argsObject = (JsonObject)args[0];
            }

            var operation = new RestOperation();

            IHttpRequest webRequest = _requestBuilder.CreateRequest(operationName, argsObject);

            webRequest.BeginGetResponse(ar => InterpretResponse(responseProcessor, operation, () => webRequest.EndGetResponse(ar)), null);

            return(operation);
        }