0
var   all: TThreadList = nil;

procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
var  list:tlist;
begin
  try
  list := all.LockList;
  try
    list.Add(0);
  finally
    all.UnlockList;
  end;
  except

  end;
end;

telnet 127.0.0.1 1234

why it's getting access violation ?

jmp
  • 2,456
  • 3
  • 30
  • 47

1 Answers1

8

I expect you simply forgot to create the TThreadList. You need

all := TThreadList.Create;

somewhere. For example, in the initialization section of that unit.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490