G
gxw
Unregistered / Unconfirmed
GUEST, unregistred user!
想在主窗口用adoquery1+dbgrideh显示记录,子线程则负责接收并写记录,然后刷新dbgrideh的显示.但目前却遇到了子线程内无法执行adoquery1.DisableControls的问题,弄的dbgridEh不断闪烁.....用过定义临界区的办法也无效.严重郁闷~~[][]
procedure TForm1.bitbtn1Click(Sender);
//------主程序
begin
with adoquery1do
begin
close;
sql.clear;
sql.add('select * from Table1');
open;
//---启动线程
StopThread:=False;
//全局变量
myThread.Create(False);
end;
end;
procedure myThread.Execute;
//-------子线程
var aqu2: Tadoquery;
begin
aqu2:=TAdoQuery.Creat(Application);
repeat
try
......
...... //用aqu2控制接收和写记录到Table1内,一切正常
......
// 刷新
with form1.adoquery1do
begin
[red]DisableControls;[/red] // <---此处老报错:"ADOQuery1:Cannot perform this operation on a close dataset."
去掉则立即正常
Close;
Open;
[red]EnableControls;[/red]
end;
except
on E: Exceptiondo
ShowMessage(E.message);
end;
until StopThread;
aqu2.free;
end;
procedure TForm1.bitbtn1Click(Sender);
//------主程序
begin
with adoquery1do
begin
close;
sql.clear;
sql.add('select * from Table1');
open;
//---启动线程
StopThread:=False;
//全局变量
myThread.Create(False);
end;
end;
procedure myThread.Execute;
//-------子线程
var aqu2: Tadoquery;
begin
aqu2:=TAdoQuery.Creat(Application);
repeat
try
......
...... //用aqu2控制接收和写记录到Table1内,一切正常
......
// 刷新
with form1.adoquery1do
begin
[red]DisableControls;[/red] // <---此处老报错:"ADOQuery1:Cannot perform this operation on a close dataset."
去掉则立即正常
Close;
Open;
[red]EnableControls;[/red]
end;
except
on E: Exceptiondo
ShowMessage(E.message);
end;
until StopThread;
aqu2.free;
end;