1)[美] Jeffrey Richter
Windows NT 高级编程技术.
中提到:
当线程是由于自然原因或自杀而死亡时,该线程中的堆栈将被撤销.
但是该线程如果是他杀(调用TeriminateThread),windows在拥有该
线程的进程退出之前不会撤销该堆栈.
另外,在线程终止时,windows将通知所有挂接在这个拥有终止线程的
进程上的Dlls,告诉它们线程将被终止.但是他杀的不会.例如,在线程
脱离与某个Dll的挂接时,该Dll可能要往磁盘上刷新数据,如果dll
没有得到通知,.....
同样TerminateProcess也是一样的.
由此,不到万不得已,不要使用TerminteThred和TerimnateProcess!!!!!
2)Delphi中有关Wait的帮助中提到:
Don't call WaitFor in the context of the main VCL thread if the thread uses Synchronize. Doing so will either cause a deadlock, making it appear that the application has hung, or raise an EThread exception.
TMD不可理喻:(
function ThreadActive( aThread: THandle ): Boolean;
var
ExitCode: Integer; // 也许是用LongWord,我没仔细查pas文件
begin
GetExitCodeThread( aThread, ExitCode );
Result := (STILL_ACTIVE=ExitCode);
end;