如题,procedure TForm1.btn1Click(Sender: TObject);
var trdHandle:THandle;
begin
trdHandle:=CreateThread(nil,0,@ServerReader,@sockSrv,0,acThreadID);
if trdHandle=(?) then
begin
dosomething;//我想在线程退出的时候做一些事。
end;
end;
var trdHandle:THandle;
begin
trdHandle:=CreateThread(nil,0,@ServerReader,@sockSrv,0,acThreadID);
if trdHandle=(?) then
begin
dosomething;//我想在线程退出的时候做一些事。
end;
end;
WaitForSingleObject(trdHandle)怎么用,它的返回值为多少表示线程退出了。
DWORD dwMilliseconds // time-out interval in milliseconds
);Return ValuesIf the function succeeds, the return value indicates the event that caused the function to return.
If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.
The return value on success is one of the following values: Value Meaning
WAIT_ABANDONED The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.
WAIT_OBJECT_0 The state of the specified object is signaled.
WAIT_TIMEOUT