C# 如何实现程序每隔一段时间运行一下程序,需传参

xiaoshi518 2010-09-08 11:47:30
我的意思是这样的,让C#在WinForm下每从数据库读100条数据操作后,隔1~2秒钟再在原来的基础上读取后面的数据操作。


在web程序里我知道可以通过<meta http-equiv='refresh' content='1;URL=?ID=参数'>来实现上面的功能,但在C# WinForm下不知道如何处理了。
...全文
314 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-09-08
  • 打赏
  • 举报
回复
new Thread((ThreadStart)delegate
{

}).Start;

wuyq11 2010-09-08
  • 打赏
  • 举报
回复
Thread.Sleep
执行分页存储过程添加数据到List<T>或dataset
或timer定时执行thread
xiaoshi518 2010-09-08
  • 打赏
  • 举报
回复

string strSql = "select * from TableName1 where ID>=" + j + " and ID<=" + Convert.ToInt32(j + 100).ToString();
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["strConn"], CommandType.Text, strSql);
int info = 0;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
info += i;

}
MessageBox.Show(info.ToString() + "__" + j.ToString());
Thread.Sleep(10000);
j = j + 100;

这里要怎么改呢?
qiuxin425 2010-09-08
  • 打赏
  • 举报
回复
线程循环读取

每读到 inumber%100 == 0

Thread.Sleep(1000);一下
有泪为清流 2010-09-08
  • 打赏
  • 举报
回复
1楼正解
ztenv 2010-09-08
  • 打赏
  • 举报
回复
线程读取;
xiaoshi518 2010-09-08
  • 打赏
  • 举报
回复
int sum=300; //sum等于记录总数。
int j = 1;
while (j < sum)
{
string strSql = "select * from gupiao where ID>=" + j + " and ID<=" + Convert.ToInt32(j + 100).ToString();
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["strConn"], CommandType.Text, strSql);
int info = 0;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
info += i;

}
MessageBox.Show(info.ToString() + "__" + j.ToString());
textBox1.Text += "aa";
Thread.Sleep(5000);
j = j + 100;
}

总算出来了,呵呵谢谢大家。

taoistong 2010-09-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 xiaoshi518 的回复:]
我的意思是这样的,让C#在WinForm下每从数据库读100条数据操作后,隔1~2秒钟再在原来的基础上读取后面的数据操作。


在web程序里我知道可以通过<meta http-equiv='refresh' content='1;URL=?ID=参数'>来实现上面的功能,但在C# WinForm下不知道如何处理了。
[/Quote]


上面的都可以
或者设置一个timer
wentao1114 2010-09-08
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 deyygywxf 的回复:]
线程循环读取

每读到 inumber%100 == 0

Thread.Sleep(1000);一下
[/Quote]
..
deyygywxf 2010-09-08
  • 打赏
  • 举报
回复
线程循环读取

每读到 inumber%100 == 0

Thread.Sleep(1000);一下
anbin0814 2010-09-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 qiuxin425 的回复:]
线程循环读取

每读到 inumber%100 == 0

Thread.Sleep(1000);一下
[/Quote]
+1
Teng_s2000 2010-09-08
  • 打赏
  • 举报
回复
aahujunaa 2010-09-08
  • 打赏
  • 举报
回复
for(int i=0;;i++){
string strSql = "select top(100) * from TableName1 where ID not in (select top (i*100) * from TableName1)
}

111,129

社区成员

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

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

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