Newbie question: I have a forms application. It has a separate thread which makes a web services call, and then posts the results of the call to the main form.
In my thread, after X seconds have passed (using a TTimer), I call:
procedure TPollingThread.OnTimer(Sender: TObject);
var
SystemProbeValues : TCWProbeValues;
begin
SystemProbeValues := Remote.Run.GetSystemProbeValues;
PostMessage( ParentHandle, WM_APIEVENT ,Integer(apiMultiCellStatus), Integer(SystemProbeValues) );
end;
The function Remote.Run.GetSystemProbeValues has the following prototype:
function GetSystemProbeValues : TCWProbeValues; stdcall;
And TCWProbeValues is a dynamic array of TCWProbeValue objects (which all descend from TRemotable).
In my main form, I receive the message just fine and cast the LParam back to TCWProbeValues:
procedure TFrmCWMain.OnAPIEvent(var msg: TMessage);
begin
ProbeValues := TCWProbeValues(msg.LParam);
end;
My question is, given that the dynamic array and its objects were created by the Delphi HTTORIO system, who is responsible for freeing them? Did Delphi consider that memory re-usable after my OnTimer function returned? (And in which case, its pure good luck that my main form message handler can actually read the memory referenced by the LParam of the message?) Or rather, is it my responsibility to free the object auto-instantiated by the HTTPRIO request?
Many thanks, please shout if the above needs more detail / code and I'll add to it!
Cheers, Duncan