static bool ProcessAsyncResponseStreamResult(XmlRpcAsyncResult result,
     IAsyncResult asyncResult)
 {
     int endReadLen = result.ResponseStream.EndRead(asyncResult);
       long contLen = result.Response.ContentLength;
       bool completed;
       if (endReadLen == 0)
     completed = true;
       else if (contLen > 0 && endReadLen == contLen)
       {
     result.ResponseBufferedStream = new MemoryStream(result.Buffer);
     completed = true;
       }
       else
       {
     if (result.ResponseBufferedStream == null)
     {
       result.ResponseBufferedStream = new MemoryStream(result.Buffer.Length);
     }
     result.ResponseBufferedStream.Write(result.Buffer, 0, endReadLen);
     completed = false;
       }
       if (completed)
     result.Complete();
       return completed;
 }
 static void ReadAsyncResponse(XmlRpcAsyncResult result)
 {
     if (result.Response.ContentLength == 0)
       {
     result.Complete();
     return;
       }
       try
       {
     result.ResponseStream = result.Response.GetResponseStream();
     ReadAsyncResponseStream(result);
       }
       catch (Exception ex)
       {
     ProcessAsyncException(result, ex);
       }
 }
 static void ProcessAsyncException(XmlRpcAsyncResult clientResult,
     Exception ex)
 {
     WebException webex = ex as WebException;
       if (webex != null && webex.Response != null)
       {
     clientResult.Response = webex.Response;
     return;
       }
       if (clientResult.IsCompleted)
     throw new Exception("error during async processing");
       clientResult.Complete(ex);
 }