Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
Delphi 10.2 Tokyo Professional
|
Re: Objekt in Thread und Mainthread verwenden
1. Apr 2010, 19:48
Ehm also.. das heißt ich mache einfach folgendes:
Delphi-Quellcode:
// als privates Feld z.B.
var CS: TCriticalSection;
procedure TClientThread.Execute;
var Buff: TBytes;
begin
while not Terminated do
begin
CS.Enter;
try
if not FClient.FTCPClient.Connected then continue;
if not FClient.FTCPClient.Socket.InputBufferIsEmpty then
begin
FClient.FTCPClient.Socket.ReadBytes(Buff,FClient.FTCPClient.Socket.InputBuffer.Size);
FClient.FBuffer.Write(Buff[0],Length(Buff));
Synchronize(FClient.ReceiveData);
end;
finally
CS.Leave;
end;
sleep(5);
end;
end;
und alles ist gut?
Michael "Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
|