
2008-7-3 19:02
handuner
C#(C/S) 执行时间时间过长,界面白白一片,怎么处理
刚刚入手C/S程序
数据一次处理比较多,一次执行时间超过半小时,
执行的时候,就像WINDOWS下未响应的样子
怎么处理,怎么才能在界面显示进度
我大概知道应该是用进程处理,
所以大家不要光讲理论,贴点演示代码
2008-7-3 19:02
cayman811
C# codeThread th = new Thread(new ThreadStart(DataProcess));
th.Start();
2008-7-3 19:02
duxiaochu1972
你可以做个等待框
参考下BackGroundWorker
2008-7-3 19:03
lazycat001
C# code
....
step = quan / 5;
sreach sr1 = new sreach(start, (start + step));
start += step;
sreach sr2 = new sreach(start, (start + step));
start += step;
sr1.thd.Join();
sr2.thd.Join();
sreached = sr1.userful + sr2.userful;
label15.Text = sreached.ToString();
....
C# code
class sreach
{
public int start;
public int end;
public int userful;
public Thread thd;
public sreach(int s1, int e1)
{
userful = 0;
start = s1;
end = e1;
thd = new Thread(this.run2);
thd.Start();
}
void run2()
{
common comm = new common();
string type = "";
string description = "";
DataSet ds = null;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString))
{
//这里放执行代码
}
}
}
2008-7-6 16:08
smthgdin
用delegate,委托的方法起一个线程专门查询数据库,查询完了回调到窗体中。其实就像是消息处理那样。
2008-7-7 20:33
VagrantLee
google上搜索一下吧,很多例子的!
2008-7-8 23:12
cnhzlt
多线程
2008-9-19 13:03
chiansy_ruan
为什么一次作业要处理那么多的数据?
半小时不是可以容忍的效率...
2008-10-1 21:51
liuhongzhe
其实不用那么复杂,直接在窗体标题上显示百分比就可以,这样代码是最少的。而且还简单。
到出Excel时间长,我就这么干过。没必要用进程,会带来更多的麻烦。
改窗体标题的代码不用我给你贴出来吧。
2008-10-1 21:51
liuhongzhe
如果只是查询信息的话,建议你使用分页的存储过程。
2008-10-3 16:43
cow977
如果是你的程序在循环处理的话,只要在循环中不要独占CPU的控制权就行了.
页:
[1]

Powered by ITPUB论坛