回避策を見つけました:)
while AnyQuery.Command.State = csExecuting do
begin
Application.ProcessMessages;
//do anything here while query is executing
//the query has to be set to ResourceOptions.CmdExecMode = amAsync
end;
end;
また、次のコマンドを実行してクエリをキャンセルすることもできます
AnyQuery.AbortJob(False);
私のコードは次のようになります。
AnyQuery.Active;
ShowProgressForm:= TShowProgressForm.Create(Application);
ShowProgressForm.Label1.Caption := 'Generating Query Please Wait...';
while AnyQuery.Command.State = csExecuting do
begin
Application.ProcessMessages;
if ShowProgressForm.Cancel then
begin
AnyQuery.AbortJob(False);
ShowProgressForm.Close;
EXIT;
end;
end;
ShowProgressForm.Close;
Cancel
で宣言されたグローバルブール変数です。ボタンShowProgressForm.pas
を押すCancel
と変数になりTrue
、AbortJob(False)
メソッドはクエリの実行を中止します:)
それが役に立てば幸い :)