I have a TFrame (fraDisplay) with a TTimer (timAnimateDataChange). The timer is used to control a small animation. In the form containing the frame I want to have a method that does something like this:
procedure TForm.DoStuff;
begin
DoSomeLogicStuff;
fraDisplay.AnimateResult;
WaitForAnimationToFinish;
DoSomeOtherLogicStuff;
fraDisplay.AnimateEndResult;
WaitForAnimationToFinish;
fraDisplay.Finalize;
end;
The animations are basically redraws of a TImage32, timed by a timer. The timer will disable it self when finished, and the frame has a boolean property called AnimationRunning which will be set to false when the animation is finished.
There are no threads or anything like that to complicate or help matters.
The question is, how do I implement the WaitForAnimationToFinish-method?
(Btw, this is not a good solution:
procedure TForm.WaitForAnimationToFinish;
begin
repeat
Application.ProcessMessages;
until not fraDisplay.AnimationRunning;
end;
since the timer won't fire while the method is running :-( )