终止线程两个函数:ExitThread 和 TerminateThread
终止线程有两个函数:ExitThread 和 TerminateThread
居说这样退出线程不好,最佳的方法就是认线程函数执行完成后返回。
例如:GatherFun函数体执行完成以后,线程就退出了。
function GatherFun:Cardinal;stdcall;
begin
Form1.GatherAddr;
end;
GatherHwnd := CreateThread(nil,0,@GatherFun,nil,0,Temp);
问:怎么知道线程是否退出呢?
答:执行 if WaitForSingleObject(Thread.Handle, INFINITE) = WAIT_OBJECT_0 then 线程结束啦
或者 执行 GetExitCodeThread(GatherHwnd,i); 这两个函数百度一下有解释。