type
channelrecord=record
Flow:integer;
tempstr:string;
end; // 定义记录 private
channel:array [0..10] of channelrecord;
end;procedure Tmain.Dowork(chnl: integer);
begin
case channel[chnl].flow of
0: begin
With ADOQuery1 Do
Begin
Close;
Sql.Clear;
SQL.Add('Select top 1 * From T_Client where F_phone='''+inttostr(channelno)+''' ');
End;
TQryThread.Create(False,ADOQuery1,channelno); //想在这加入多线程,每个channel去查询数据库
end;
1: begin
//显示出查询的结果
end;end;procedure Tmain.Timer1Timer(Sender: TObject); //定时器
begin
for i :=0 to 10 do
begin
Dowork(i);
end;
end;上面是代码片段,想法就是在循环中加入多线程查询,因为channel是动态的,如果channel是10是不是要建10个线程?希望大家结点思路,感激不尽
channelrecord=record
Flow:integer;
tempstr:string;
end; // 定义记录 private
channel:array [0..10] of channelrecord;
end;procedure Tmain.Dowork(chnl: integer);
begin
case channel[chnl].flow of
0: begin
With ADOQuery1 Do
Begin
Close;
Sql.Clear;
SQL.Add('Select top 1 * From T_Client where F_phone='''+inttostr(channelno)+''' ');
End;
TQryThread.Create(False,ADOQuery1,channelno); //想在这加入多线程,每个channel去查询数据库
end;
1: begin
//显示出查询的结果
end;end;procedure Tmain.Timer1Timer(Sender: TObject); //定时器
begin
for i :=0 to 10 do
begin
Dowork(i);
end;
end;上面是代码片段,想法就是在循环中加入多线程查询,因为channel是动态的,如果channel是10是不是要建10个线程?希望大家结点思路,感激不尽
解决方案 »
- Delphi 问题
- 以本人的能力,现无法解决的几个问题(希望大家积极提供帮助)?
- (**问题没有解决,重新发贴. 总结前贴的测试结果)** 关于ADO 主从表的UpdateCatch (批量更新) 问题,请高人指教?
- 在D6里有没有IntraWeb?
- 我做了个简单的聊天程序,可是在设定远程Ip和端口已极本地端口时,却出错!
- 请问怎么分割显示png图片呢?
- 如何引用动态生成的TImage?
- 如何得到当前网上邻居上的所有的计算机,并存到一个datagrid中
- 如何判断一个文件是否存在?
- 如何对字符的某一位进行操作?
- 简单查询问题
- 请问 procedure () ... of object 是代表什么意思呢?
另外 所有的线程用一个adoquery肯定不行
还有就是 adoquery应该不是线程安全的,可能会有冲突
我没这么用过 不知道可不可以