###実現したいこと
Delphi Berlin のFiremonkeyにてスケジュール管理アプリを作っています。
DB接続にて処理に時間がかかるので、画面がフリーズしていないこと(処理中であること)をユーザに伝えたい為、AniIndicatorを使って画面上に円のインジケータを表示させたいです。
###発生している問題
DB接続処理中にて、AniIndicatorは表示されますが、円のインジケータが止まって回転しません。Android,iPhone両方とも同じ事象が発生しています。
###該当のソースコード
//スケジュール取得処理 procedure TForm1.Button2Click(Sender: TObject); var loc_sql_query : String; loc_i : Integer; loc_j : Integer; begin AniIndicator1.Visible := True; AniIndicator1.Enabled := True; Application.ProcessMessages; loc_sql_query := SELECT * ... //割愛 //DB接続 ClientModuleUnit1.ClientModule1.ServerMethods1Client.Set_sql_query_temp(loc_sql_query); ClientModuleUnit1.ClientModule1.cds_QueryTemp.Close; ClientModuleUnit1.ClientModule1.cds_QueryTemp.Open; ClientModuleUnit1.ClientModule1.cds_QueryTemp.First; //StringGridの描画設定 loc_j := 0; StringGrid1.RowCount := ClientModuleUnit1.ClientModule1.cds_QueryTemp.RecordCount; while not ClientModuleUnit1.ClientModule1.cds_QueryTemp.Eof do begin loc_i := 0; while loc_i < 2 do begin if loc_i = 0 then begin //開催日時 StringGrid1.Cells[loc_i,loc_j] :=ClientModuleUnit1.ClientModule1.cds_QueryTemp.FieldByName('START_DATE_TIME').AsString; end else begin //サービス名 StringGrid1.Cells[loc_i,loc_j] :=ClientModuleUnit1.ClientModule1.cds_QueryTemp.FieldByName('SERVICE_NAME').AsString; end; INC(loc_i); end; INC(loc_j); ClientModuleUnit1.ClientModule1.cds_QueryTemp.Next; end; AniIndicator1.Visible := False; AniIndicator1.Enabled := False; Application.ProcessMessages; end;
###試したこと
TThread.CreateAnonymousThread を使い、別スレッドにて処理を行ってもみましたが実現できませんでした。
TThread.CreateAnonymousThread( procedure() begin try TThread.Synchronize(TThread.CurrentThread,procedure begin AniIndicator1.Visible := True; AniIndicator1.Enabled := True; Application.ProcessMessages; //上記と同じく、DB接続とStringGridへの描画 AniIndicator1.Visible := False; AniIndicator1.Enabled := False; Application.ProcessMessages; end); finally end; end).Start; end;
###補足情報
<開発環境>
Delphi 10.1 Berlin update2 (Win-64bit)
DataSnapサーバを用いてDB接続を実施
DataBase:FireBird
<検証端末>
Android (4.4.2)
iPhone (iOS 10.2)
あなたの回答
tips
プレビュー