I'm trying to build a generic worker thread in Delphi, one that I can pass a function/procedure (doesn't matter) as an argument and let it execute.
My guess is to add a field in the TThread class and call it from TThread.Execute.
So the code outside the thread is gonna be:
MyThread := TWorkerThread.Create(True);
Mythread.CallBackF := @Foo;
try
MyThread.Resume;
except
MyThread.Free;
end;
How do I keep a reference of @foo in the TWorkerThread and call it from inside Execute?