I am using Delphi XE-5 (Firemonkey Mobile Application)
I am trying to get the TAniIndicator to work, by displaying during my long processing. I have a TAniIndicator (Ani
The problem come from the timer Inside the TAnimation, by chance Embarcadero add a global variable.
Add the following code in your FormCreate procedure
{$IFDEF IOS}
AniFrameRate := 10;
{$ENDIF}
Your main thread needs to stay responsive to the message queue while your long process is running. If not, you are blocking the animation (and other aspects of the UI) from receiving new messages, like paint requests and timers notifies. You need to move any long processing to a separate thread instead. Start the thread and then start the animation. Let the main thread handle the UI normally in the meantime. When the thread is finished, have it notify the main thread, which can then stop the animation, and finish any other processing it needs on the result of the thread, if any. For example:
type
TLoadThread = class(TThread)
public
Host: string;
NamePath: string;
Port: Integer;
Config: Boolean;
constructor Create(const aHost, aNamePath: string; aPort: Integer; aConfig: Boolean); reintroduce;
protected
procedure Execute; override;
end;
constructor TLoadThread.Create(const aHost, aNamePath: string; aPort: Integer; aConfig: Boolean);
begin
inherited Create(True);
FreeOnTerminate := True;
Host := aHost;
NamePath := aNamePath;
Port := aPort;
Config := aConfig;
end;
procedure TLoadThread.Execute;
begin
//do processing
Synchronize(
procedure
//update main form
end
);
//do processing
end;
var
Loading: Boolean = False;
zLThread: TLoadThread = nil;
procedure TfrmMain.FormActivate(Sender: TObject);
begin
zLThread := TLoadThread.Create(Host, NamePath, Port, Config);
zLThread.OnTerminate := ThreadTerminated;
zLThread.Start;
Loading := True;
AniIndi.Visible := True;
AniIndi.Enabled := True;
UpdateAll;
end;
procedure TfrmMain.ThreadTerminated(Sender: TObject);
begin
zLThread := nil;
Loading := False;
AniIndi.Enabled := False;
AniIndi.Visible := False;
UpdateAll;
end;