procedure TClientHandleThread.Execute;
begin
inherited;
while not Terminated do
begin
try
Application.ProcessMessages;
CB := UDPMainForm.UDPClient.ReceiveString();
Synchronize(HandleInput);
except
end;
end;
end;
procedure TClientHandleThread.HandleInput;
begin
if Trim(CB) <> '' then
UDPMainForm.mmoRecive.Lines.Add(FormatDateTime('yyyy-mm-dd hh:mm:ss', Now)
+',收到服务器发来的消息:' +cb);
end;
procedure TRecThread.Execute;
var
ires,i,j : integer;
recMsg : TMyMsg;
stmp,tmpName,tmpRealName,tmpDept,pointDept : String;
sNode,ss : TTreeNode;
begin
{ Place thread code here }
FreeOnTerminate := True;
while ((not Terminated) and DM.tcpLog.Connected) do
begin
ires := DM.tcpLog.ReadFromStack; //........
if ires > 0 then
begin
DM.tcpLog.ReadBuffer(recMsg,sizeof(recMsg));
...
接收的方法很多,自己选择