private WaitForResponse ( ) : |
||
return |
/// <summary> /// /// </summary> /// <param name="asr"></param> /// <param name="returnType"></param> /// <returns></returns> public object EndInvoke(IAsyncResult asr, Type returnType) { object reto = null; Stream responseStream = null; try { XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)asr; if (clientResult.Exception != null) { throw clientResult.Exception; } if (clientResult.EndSendCalled) { throw new Exception("dup call to EndSend"); } clientResult.EndSendCalled = true; if (clientResult.XmlRpcRequest != null && returnType != null) { clientResult.XmlRpcRequest.ReturnType = returnType; } HttpWebResponse webResp = (HttpWebResponse)clientResult.WaitForResponse(); #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) clientResult._responseCookies = webResp.Cookies; clientResult._responseHeaders = webResp.Headers; #endif responseStream = clientResult.ResponseBufferedStream; if (ResponseEvent != null) { OnResponse(new XmlRpcResponseEventArgs( clientResult.XmlRpcRequest.proxyId, clientResult.XmlRpcRequest.number, responseStream)); responseStream.Position = 0; } #if (!COMPACT_FRAMEWORK && !FX1_0 && !SILVERLIGHT) responseStream = MaybeDecompressStream((HttpWebResponse)webResp, responseStream); #endif XmlRpcResponse resp = ReadResponse(clientResult.XmlRpcRequest, webResp, responseStream); reto = resp.retVal; } finally { if (responseStream != null) { responseStream.Close(); } } return(reto); }
public object EndInvoke( IAsyncResult asr, Type returnType) { object reto = null; WebResponse webResp = null; Stream responseStream = null; try { XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)asr; if (clientResult.Exception != null) { throw clientResult.Exception; } if (clientResult.EndSendCalled) { throw new Exception("dup call to EndSend"); } clientResult.EndSendCalled = true; webResp = clientResult.WaitForResponse(); responseStream = clientResult.ResponseBufferedStream; XmlRpcResponse resp = ReadResponse(clientResult.XmlRpcRequest, webResp, responseStream, returnType); reto = resp.retVal; } finally { if (responseStream != null) { responseStream.Close(); } if (webResp != null) { webResp = null; } } return(reto); }