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); }
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); }
public HttpResponseMessage EndSend(IAsyncResult result) { var state = HttpStageProcessingAsyncResult.End(result, true); return(state.Response); }