| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1091 人关注过本帖
标题:c# Windows Mobile 下HttpWebRequest请求几次之后死掉,不再发出请求
取消只看楼主 加入收藏
tiantangniao
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-1
收藏
 问题点数:0 回复次数:0 
c# Windows Mobile 下HttpWebRequest请求几次之后死掉,不再发出请求
代码如下所示:
  public void remotebidui(object res)
        {
            //去远程取回XML文档,然后解析XML文档
             ReturnResult result = new ReturnResult();
            try
            {
                result = (ReturnResult)res;
                //res
            }
            catch (Exception err)
            {
                MessageBox.Show("cast",err.Message);
            }
            this.sfzh = result.sValue;
            this.strStatusValue = result.returnRange;
            try
            {
               
                 if (strStatusValue.Equals("在逃"))
                {
                    rangeStr = "10000000";
                    
                }
                if (sfzh != "") { URI = config.biduiurl + "?pid=" + sfzh+"&range="+rangeStr; }
               // MessageBox.Show("sfzh:"+sfzh+",uri:"+config.biduiurl+",pid:"+sfzh+",range:"+rangeStr);
                // InternetSetCookie(URI, "", config.cookie);
                HttpWebRequest request = WebRequest.Create(URI) as HttpWebRequest;
                request.Headers.Add("COOKIE",config.cookie);
                request.Method = "GET";
                request.KeepAlive = false;
                request.Timeout = 120000;
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                responseStream = response.GetResponseStream();
                reader = new (responseStream, Encoding.Default);
                string srcString = reader.ReadToEnd();
              //  MessageBox.Show("srcString:" + srcString);
                request = null;
               
              //  request.ServicePoint.ConnectionLimit = 8;
               // request.ServicePoint.ConnectionLimit = 200;
                response.Close();
                reader.Close();
                reader.Dispose();
                responseStream.Close();
                responseStream.Dispose();
                delegateEvent additemevent = additem;
               
                ReturnResult result1 = new ReturnResult();
                result1.sValue = srcString;
                result1.returnRange = rangeStr;
                if (additemevent != null)
                {
                    additemevent(result1);
                }
            }
            catch (Exception ee)
            {
                   string s = "<root><alarm>" + ee.Message + "</alarm><sfzh></sfzh><xm></xm><description></description></root>";
              //  MessageBox.Show("000000");     
                delegateEvent additemevent = additem;
                ReturnResult result1 = new ReturnResult();
             //   MessageBox.Show("1111");
                result1.sValue = s;
                //result1.returnRange = "00000000";
                result1.returnRange = rangeStr;
                if (additemevent != null)
                {
                    additemevent(result1);
                }
            }
            finally {
            
            }
            

        }
使用线程进行请求:
  if (strStatue.Substring(0, 1).Equals("1"))
            {

                ReturnResult result = new ReturnResult();
                result.returnRange = "在逃";
                result.sValue = sfzh;
                object obj = (object)result;
                bidui bd = new bidui(obj);
                bd.additem += AddItemEvent;
                WaitCallback w = new WaitCallback(bd.remotebidui);
                ThreadPool.QueueUserWorkItem(w, obj);

            }
            
出现问题: webrequest请求几次后就没反应了,一般request能请求个10来次就死掉了。
请大家帮忙解决,谢谢!!
搜索更多相关主题的帖子: Windows 请求 Mobile 
2010-04-01 20:46
快速回复:c# Windows Mobile 下HttpWebRequest请求几次之后死掉,不再发出请求
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061713 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved