0
I have a thread that performs a action and in onterminate performs a secondary process.
It works that way:
procedure qualquer;
var
Thread: TThread;
begin
Thread.CreateAnonymousThread(
procedure()
begin
excecuta ação
end;
//como quero que fique - adicionando parametros
Thread.OnTerminate:= concluiacao(parametro sender, outro parametro);
//como faço
Thread.OnTerminate:= concluiacao;
Thread.Start;
end;
then I run the second trial
procedure concluiacao(Sender: TObject);
begin
if TThread(Sender).FatalException <> nil then
begin
ShowMessage(TThread(Sender).FatalException.ToString);
Exit;
end
else
continua os processos normalmente;
end;
I would like to send new parameters in the thread onterminate, but the first parameter is a Sender, and I don’t know how to send it.
var Thread: Tthread; --> here must be a descendant of Tthread.
– Ricardo Alves Carvalho
Sender is Thread itself. You can declare properties on the descendant and read their values in Onterminate. Just make a Typecast.
– Ricardo Alves Carvalho
I even tried some codes as a conclusion(Thread), conclusion(Tthread(Thread)) or conclusion(Tobject(Thread)), but they didn’t work.
– Maurício
Check out this link: https://stackoverflow.com/questions/34890222/createanonymousthread-with-parameters
– Ricardo Alves Carvalho