I want to show a (animated) GIF in a TImage (GIF) while the main programming is running. Right now, either the main program waits for the GIF, or the GIF is waiting for the main program (thread) before showing.
My idea is that the GIF Image should be run in a separate thread. The GIF image is not used elsewhere in the main program. I have read a lot about multi-threading (new to me). Delphi allows me to build a new thread in a separate unit (a built-in feature), but many on-line examples and tutorials just put the TThread object on the main form. If I do that I get a compiler error that my mainform does not contain a member named 'Execute' See code).
What am I doing wrong? Should I go for the separate thread in the second unit? Any advise on how to access this GIF (TImage) via this separate thread? I do know that I have to take care of synchronization between the VCL and the separate thread. I also read that modern Delphi has a Queue possibility, claimed to be superior over synchronization.
(in the interface section):
type
TThreadGIF = class(TThread)
protected
procedure Execute; override;
end;
(in the implementation section, below the {$R *.dfm}):
procedure TThreadGIF.Execute;
begin
NameThreadForDebugging('ThreadGIFname');
{ code should start here }
end;
If anybody knows a reference to a good tutorial, would also help.
How To Build Multithreaded Applications brings me in my current position.