Update: It was not clear what I was asking so I updated the question.
Update: It was not clear what I was asking so I updated the question.
I am trying to call RTTI Invoke from within TTask.Run and I get an AV.
I have this code:
function getProc(const aMethod: TRTTIMethod; const aObject: TObject; const aParams: array of TValue);
begin
return:=procedure
begin
aMethod.Invoke(aObject, aParams);
end;
end;
...then somewhere else...
TTask.Run(getProc(myMethod, myObj, myParams);
I get an AV with Invoke. If I remove the call and add some other code that does not use any of the aMethod, aObj, aParams it works correctly.
I have, also, tried to use private fields to pass the params in getProc
I am trying to call RTTI Invoke from within TTask.Run and I get an AV.
I have this code:
function getProc(const aMethod: TRTTIMethod; const aObject: TObject; const aParams: array of TValue);
begin
return:=procedure
begin
aMethod.Invoke(aObject, aParams);
end;
end;
...then somewhere else...
TTask.Run(getProc(myMethod, myObj, myParams);
I get an AV with Invoke. If I remove the call and add some other code that does not use any of the aMethod, aObj, aParams it works correctly.
I have, also, tried to use private fields to pass the params in getProc
Eric BergerPanagiotis Drivilas That's it. Many Thanks
ReplyDeletePanagiotis Drivilas A small tweak; you can write method:=context.GetType(self.classType).GetMethod('Test') directly. Ευχαριστώ
ReplyDeleteI would guess that the TRttiMethod instance might not be alive anymore when you invoke the code since the TRttiContext has gone out of scope and all instances created by it are destroyed then as well.
ReplyDelete