ContextSwitchDeadLock 和dataTable的循环问题

ruilab 2012-01-10 09:28:25
SqlConnection connectionObj1 = new SqlConnection(constr);  //建立连接对象
connectionObj1.Open(); //连接打开
string SqlCom1 = "select top (50) id,url,yn,sex FROM [58].[dbo].[58url] where yn='N'";
SqlCommand obj1 = new SqlCommand(SqlCom1, connectionObj1);

da1.SelectCommand = obj1;

da1.Fill(Table1);
dataGridView1.DataSource = Table1;

connectionObj1.Close();//连接关闭




使用for (int j = 0; j < Table1.Rows.Count; j++)
{
HttpWebRequest,HttpWebResponse打开网址
提取数据
其中request.Headers.Add(HttpRequestHeader.Cookie, webBrowser1.Document.Cookie);
}


select top (20)..
select top (50)..
不出现ContextSwitchDeadLock的情况
select top (100)..
出现ContextSwitchDeadLock的情况


请教一下如何解决这个问题!
...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruilab 2012-01-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jiuhexuan 的回复:]

.net中的ContextSwitchDeadlock异常解决
http://doudoubear11.blog.163.com/blog/static/3012624320110741311530/
[/Quote]

这个不能根本解决问题。

程序导致内存泄露,猛涨到1G。
就算改了提示,程序依旧运行不下去。
jiuhexuan 2012-01-10
  • 打赏
  • 举报
回复
.net中的ContextSwitchDeadlock异常解决
http://doudoubear11.blog.163.com/blog/static/3012624320110741311530/
ruilab 2012-01-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jiuhexuan 的回复:]

嗯,哪个资源没有做回收?

尽量用静态或者一个对象,不要一直new
[/Quote]

是这个问题了。
jiuhexuan 2012-01-10
  • 打赏
  • 举报
回复
嗯,哪个资源没有做回收?

尽量用静态或者一个对象,不要一直new

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧