If I run this code, the outcome is unexpected as the strings in the thread dont have the correct values:
procedure TMain.FollowBose(Speakername: string; NewState: Boolean);
{..}
procedure TMain.ProcessRoomMotionResponse(Rooms: TJSONArray; Response: TJSONObject);
var
ParamName1: string;
ParamName2: string;
Room: tJSONValue;
RoomData: TJSONObject;
Roomname: string;
Motion: Boolean;
begin
if Assigned(Rooms) then begin
ParamName1 := 'Room';
ParamName2 := 'Motion';
for Room in Rooms do begin
RoomData := Room as TJSONObject;
if Assigned(RoomData.Values[ParamName1]) and Assigned(RoomData.Values[ParamName2]) then begin
Roomname := RoomData.Values[ParamName1].Value;
Motion := RoomData.Values[ParamName2].AsType<Boolean>;
LogWrite('Launching sub for ' + Roomname + '-FollowUp.', Debug);
TThread.CreateAnonymousThread(
procedure
begin
FollowUp(Roomname, Motion);
end).Start;
end;
end;
end;
end;
Is this to be expected because of Strings being special?