唐
唐晓锋
Unregistered / Unconfirmed
GUEST, unregistred user!
用ctThreadBlocking的时候用到以下代码:
procedure TUserThread.ClientExecute;
var
Data: ^byte;
SocketStream: TWinSocketStream;
begin
while not Terminated and ClientSocket.Connected do
try
SocketStream := TWinSocketStream.Create(ClientSocket, 1000);
GetMem(Data, 1024);
try
FillChar(Data^, 1024, 0);
if SocketStream.Read(Data^, 1024) = 0 then
begin
ClientSocket.Close;
Terminate;
end
else
begin
SocketStream.Write(Data^, strlen(PChar(Data)));
end;
finally
SocketStream.Free;
FreeMem(Data, 1024);
if not ClientSocket.Connected then
Terminate;
end;
except
ClientSocket.Close;
Terminate;
HandleException;
end;
end;
当客户断了以后,该线程还在运行,一直到等到TIMEOUT的时候才会退出
并且会出现一个RUNTIME ERROR.在线程外用TERMINATE之后,该线程还
是存在.
如何才能把这个线程KILL掉,要狠,要干净利落.
该问题的分值为0,是因为我怕到时候友是不了了之
<font color>该问题的分值为300分,今晚解决500分</font>
procedure TUserThread.ClientExecute;
var
Data: ^byte;
SocketStream: TWinSocketStream;
begin
while not Terminated and ClientSocket.Connected do
try
SocketStream := TWinSocketStream.Create(ClientSocket, 1000);
GetMem(Data, 1024);
try
FillChar(Data^, 1024, 0);
if SocketStream.Read(Data^, 1024) = 0 then
begin
ClientSocket.Close;
Terminate;
end
else
begin
SocketStream.Write(Data^, strlen(PChar(Data)));
end;
finally
SocketStream.Free;
FreeMem(Data, 1024);
if not ClientSocket.Connected then
Terminate;
end;
except
ClientSocket.Close;
Terminate;
HandleException;
end;
end;
当客户断了以后,该线程还在运行,一直到等到TIMEOUT的时候才会退出
并且会出现一个RUNTIME ERROR.在线程外用TERMINATE之后,该线程还
是存在.
如何才能把这个线程KILL掉,要狠,要干净利落.
该问题的分值为0,是因为我怕到时候友是不了了之
<font color>该问题的分值为300分,今晚解决500分</font>