Edit: Now that I have a better idea of what is going on, I think I can better phrase this question so it is more useful.
I am trying to replicate the following delphi code in C++
TThread.Queue(nil,
procedure
begin
LogMessage("test");
end
);
The purpose of the code is to call a method which updates a TMemo
on a form in a thread safe manner. Here is the C++ version of the method I am trying to call with Thread.Queue
void __fastcall TClientForm::LogMessage( String message )
{
MemoLog->Lines->Add( message );
}
Because I am using a BCC32 compiler without CLANG enhancements, using a Lambda is not an option. Instead according to this documentation I need to create a class which inherits from TThreadProcedure
which overrides the Invoke()
method to do the work I need done. Then I can pass an instance of that class into TThread::Queue
.
I created the following class which inherits TThreadProcuedure
and contains an invoke method.
class TMyThreadProcedure : TThreadProcedure
{
void __fastcall Invoke( String message );
};
However, since TThreadProcedure
is an abstract class, I cannot simply create an instance of it to pass into TThread::Queue
. What is the proper way to inherit from TThreadProcedure
and define a function to be called when I pass an instance of my class into TThread::Queue
?