掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Thread内でTableの読み込みを行うには? (ID:8818)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
はじめまして。 あるTableのFieldをStringListに追加していき、StringListのFindを使用して、入力データのチェックに使用しています。 Tableのレコード数が数万件あり時間がかかるため、Threadを利用してユーザーには、読み込み中に他の操作を出来ようにしてあります。 type TForm1 = class(TForm) Keytable: TTable; Keyfield: TStringField; procedure FormPaint(Sender: TObject); private public FKeyList:TstringList; end; var Form1: TForm1; implementation {$R *.dfm} type TGetKey=class(TThread) //キー項目を読み込むThread private FEof:Boolean; Procedure OpenTable; Procedure GetField; Procedure CloseTable; protected procedure Execute; override; public constructor Create; end; procedure TGetKey.OpenTable; //テーブルをオープン begin Form1.Keytable.Active:=true; FEof:=Form1.Keytable.Eof end; Procedure TGetKey.GetField; //キー項目をStringListに追加 begin with Form1 do begin FKeyList.add(Keyfield.asstring); Keytable.Next; FEof:=Keytable.Eof end end; Procedure TGetKey.CloseTable; //テーブルをクローズ begin Form1.Keytable.Active:=False end; constructor TGetKey.Create; begin FreeOnTerminate := True; inherited Create(False) end; procedure TGetKey.Execute; begin Synchronize(OpenTable); while not FEof do Synchronize(GetField); Synchronize(CloseTable) end; procedure TForm1.FormPaint(Sender: TObject); begin FKeyList:=TstringList.Create; TGetKey.Create; Onpaint:=nil end; しかし、Synchronizeメソッドは一旦threadを停止させるためが無駄なように思います。Executeメソッド内でTableの読み込みは可能でしょうか?識者のお知恵を貸してください。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.