Both constructs in the below code give error E2555 Cannot capture symbol WriteToXMLFile
Why is that?
I had a similar warning when I tried to use AParameter in the anonymous proc, and solved it by using a local 'lParameter := AParameter', so I thought a local proc would work as well....
Since WriteToXMLFile contains code I do no want to replicate, where is the proper location to define it?
procedure DoStuff(AParameter: Integer);
procedure WriteToXMLFile;
begin
// ...
end;
begin
(* 1 *)
if GetCurrentThreadID= MainThreadID then
WriteToXMLFile
else
TThread.Synchronize(nil,WriteToXMLFile);
(* 2 *)
if GetCurrentThreadID= MainThreadID then
WriteToXMLFile
else
TThread.Synchronize(nil,procedure
begin
WriteToXMLFile;
end);
end;