so sieht mein Thread objekt aus
Delphi-Quellcode:
TClientConnectorThread = class(TThread)
private
fCS : TCriticalSection;
fClient : TClientSocket;
public
Procedure SetClientData(Client : TClientSocket);
protected
Procedure Execute; override;
end;
//...
procedure TClientConnectorThread.SetClientData(Client: TClientSocket);
begin
fClient := Client;
end;
procedure TClientConnectorThread.Execute;
begin
inherited;
fCS := TCriticalSection.Create;
//while true do
repeat
begin
if not fClient.Active then
begin
fCS.Enter;
fClient.Close;
fClient.Open;
fClient.Active := true;
while not fClient.Socket.Connected do
begin
sleep(1);
fClient.Active := true;
application.ProcessMessages;
end;
fCS.Leave;
end;
sleep(1);
end until Terminated;
fCS.Free;
end;