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
?
Also, a good start into using generic threads would be AsyncCalls or Omni Thread Library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With