抢分,哈哈
procedure FreeThread(_Thread: TThread);
var
i: Integer;
iExitCode: Cardinal;
begin
iExitCode := 0;
with _Threaddo
try
FreeOnTerminate := False;
Terminate;
if Suspended then
Resume;
for i := 1 to 20do
//等待线程退出
begin
GetExitCodeThread(Handle, iExitCode);
if iExitCode = STILL_ACTIVE then
Sleep(100)
else
break;
end;
if iExitCode = STILL_ACTIVE then
TerminateThread(Handle, iExitCode);
//强制结束线程
finally
Free;
end;
end;