public override WebResponse EndGetResponse(IAsyncResult ar) { HttpWebAsyncResult async_result = ar as HttpWebAsyncResult; if (async_result == null) { throw new ArgumentException("asyncResult"); } try { if (!async_result.IsCompleted) { async_result.AsyncWaitHandle.WaitOne(); } if (async_result.HasException) { throw async_result.Exception; } try { return(new ClientHttpWebResponse(this, response)); } catch (TargetInvocationException tie) { throw tie.InnerException; } } finally { async_result.Dispose(); } }
public override WebResponse EndGetResponse(IAsyncResult asyncResult) { try { if (async_result != asyncResult) { throw new ArgumentException("asyncResult"); } if (aborted) { NativeMethods.http_request_abort(native); throw new WebException("Aborted", WebExceptionStatus.RequestCanceled); } if (!async_result.IsCompleted) { async_result.AsyncWaitHandle.WaitOne(); } if (async_result.HasException) { throw async_result.Exception; } response = async_result.Response as BrowserHttpWebResponse; } finally { async_result.Dispose(); managed.Free(); } return(response); }
public override WebResponse EndGetResponse(IAsyncResult asyncResult) { try { CheckProtocolViolation(); if (async_result != asyncResult) { throw new ArgumentException("asyncResult"); } if (aborted) { throw new WebException("Aborted", WebExceptionStatus.RequestCanceled); } // we could already have an exception waiting for us if (async_result.HasException) { throw async_result.Exception; } if (!async_result.IsCompleted) { async_result.AsyncWaitHandle.WaitOne(); } // (again) exception could occur during the wait if (async_result.HasException) { throw async_result.Exception; } response = async_result.Response; } finally { async_result.Dispose(); } return(response); }