Beispiel #1
0
        public HttpResponseMessage Send(HttpRequestMessage request)
        {
            PrepareRequest(ref request);

            var async = new HttpStageProcessingAsyncState(GetPipeline(), request)
            {
                ForceSynchronous = true
            };
            var result = new HttpStageProcessingAsyncResult(async, null, null);
            var xyz    = HttpStageProcessingAsyncResult.End(result, true);

            if (!result.CompletedSynchronously)
            {
                throw new InvalidOperationException("didn't complete synchronously: " + result + " " + xyz.Response);
            }
            return(xyz.Response);
        }
Beispiel #2
0
        static void SendCompletedCore(IAsyncResult a)
        {
            var result = (HttpStageProcessingAsyncResult)a;
            var state  = (SendAsyncState)result.AsyncState;
            var pend   = state.Client.pendingAsync;

            if (state.Operation.UserSuppliedState != null)
            {
                lock (pend)
                {
#if DEBUG
                    bool removed = pend.Remove(state.Operation.UserSuppliedState);
                    Debug.WriteLine(state.Operation.UserSuppliedState + " removed " + removed);
#else
                    pend.Remove(state.Operation.UserSuppliedState);
#endif
                }
            }
            // false == don't throw exception
            state.AsyncState = HttpStageProcessingAsyncResult.End(result, false);

            state.Operation.PostOperationCompleted(OperationCompleted, state);
        }
Beispiel #3
0
        public HttpResponseMessage EndSend(IAsyncResult result)
        {
            var state = HttpStageProcessingAsyncResult.End(result, true);

            return(state.Response);
        }