// 回调函数的回调函数
        void ResponseCallBack(IAsyncResult result)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)result.AsyncState;
                httpResponse = (HttpWebResponse)request.EndGetResponse(result);
                Encoding     ec           = new GB2312Encoding();
                StreamReader readerStream = new StreamReader(httpResponse.GetResponseStream(), ec);
                resultStr = readerStream.ReadToEnd();

                resultStr = stringToBookinfo(ref resultStr);
                // 需要处理一下

                Dispatcher.BeginInvoke(Set);

                readerStream.Close();
            }
            catch (WebException e)
            {
                resultStr = e.Message;
            }
        }
        // post函数的回调函数
        void RequestCallBack(IAsyncResult result)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)result.AsyncState;

                Stream postStream = request.EndGetRequestStream(result);
                //byte[] argsBytes = Encoding.UTF8.GetBytes(contentStr);
                Encoding ec = new GB2312Encoding();

                byte[] argsBytes = ec.GetBytes(contentStr);
                // Add the post data to the web request
                postStream.Write(argsBytes, 0, argsBytes.Length);
                postStream.Close();

                request.BeginGetResponse(new AsyncCallback(ResponseCallBack), request);
            }
            catch (WebException e)
            {
                resultStr = e.Message;
            }
        }
Exemple #3
0
 public GB2312Decoder(GB2312Encoding encoding)
 {
     _encoding = encoding;
 }