0
I am trying to pass the reference of an object that is in a list to another list, without needing to delete the object and updating the first list so that the object is no longer referenced in it.
The code is inside a thread, but when I try to pass the object reference and delete from the list some error occurs and the list does not update the objects correctly.
Follows the code:
tthread.Queue(nil,
procedure
begin
if (ListaSala.Count < LimiteSala) and (ListaPessoas.Count > 0) then
begin
ListaSala.Add(ListaPessoas.Extract);
ListaPessoas.Items[ListaPessoas.Count-1] := nil;
ListaPessoas.Delete(ListaPessoas.Count-1);
if ListaSala.Count > 0 then
Memo1.Lines.Add(ListaSala.Items[ListaSala.Count-1].NomeToString() + ' entrou na sala');
end;
Label5.Text := ListaSala.Count.ToString;
end);
sleep(2*Segundo);
Some light?
Extract doesn’t just remove the item from the list? This set to nil and delete from the People List is really necessary?
– Tiago Rodrigues
tried to use Tobject ?
– Paz