Multithread Database Programming
unit unPrepareDataset;
interface
uses
Classes, DB, ADODB,AdoConEd;
type
TInitializeDataSet = class(TThread)
private
FDataModule:TDataModule;
FUnActiveDataSet:TDataSet;
procedure OpenDataSet;
protected
procedure Execute;
override;
public
constructor Create(DataModule:TDataModule);
end;
implementation
constructor TInitializeDataSet.Create(DataModule: TDataModule);
begin
inherited Create(True);
FDataModule:=DataModule;
Self.OnTerminate:=OnTerminate;
FreeOnTerminate := True;
Resume;
end;
procedure TInitializeDataSet.Execute;
var
i:integer;
begin
with FDataModuledo
begin
for i:=0 to ComponentCount-1do
begin
if (Components is TADOTable) then
begin
FUnActiveDataSet:=(Components as TDataSet);
Synchronize(OpenDataSet);
end;
end;
end;
end;
procedure TInitializeDataSet.OpenDataSet;
begin
FUnActiveDataSet.Open;
end;
end.