procedure TSysSQLInfoThread.DisplayInfo;
begin
frmMain.DisplaySysSQLInfo;
end;
procedure TSysSQLInfoThread.Execute;
begin
Synchronize(DisplayInfo);
end;
这主程序中的代码:
procedure TfrmMain.TimerSysSQLTimer(Sender: TObject);
begin
if SysSQLInfoThread= nil then
SysSQLInfoThread := TSysSQLInfoThread.Create(False);
end;
这是线程调的方法:
procedure TfrmMain.DisplaySysSQLInfo;
var
Query : TQuery;
begin
Query := TQuery.Create(self);
try
Query.DatabaseName := dbMain.DatabaseName;
try
while not Query.Eofdo
begin
..........
Query.Next;
end;
except
on E : Exceptiondo
showmessage(E.Message);
end;
finally
Query.Free;
SysSQLInfoThread := nil;
end;
end;