小编Tom*_*gen的帖子

如何用OmniThreadLibrary替换TThread?

我习惯于创建TThread后代来进行长时间的数据库操作.我通常的构造看起来像这样:

interface
type
  TMyDBOp = class(TThread)
  private
    FConnection: TADOConnection;
    FCommand1: TADOCommand;
    FCommand2: TADOCommand; // and many more privated objects, vars ...
    procedure InitDB;
    procedure DoneDB;
    procedure DoDBStuff; // and many more procedures and functions to structure the code
  protected
    procedure Execute; override;
  public
    constructor Create; reintroduce;
    property X: T... // and many more properties to set on thread creation
  end;

implementation

constructor TMyDBOp.Create;
begin
  inherited Create(False);
end;

procedure TMyDBOp.InitDB;
begin
  FConnection:= TADOConnection.Create(nil);
  // setup all connection props, setup all other …
Run Code Online (Sandbox Code Playgroud)

delphi omnithreadlibrary

5
推荐指数
0
解决办法
667
查看次数

标签 统计

delphi ×1

omnithreadlibrary ×1