假设有个线程在dll里创建。
线程的execute方法如下:
while 1=1 do
begin
if Terminated then
break;
sleep(5000);
end;
在这里可能会出现一个问题。
当线程执行sleep(5000)时,那么线城会在execute方法中停留5秒,而在这5秒内,我把dll释放了。5秒后线程退出execute方法,但是这时候已经找不到该方法了,所以会出问题,应该用什么办法解决啊。
线程的execute方法如下:
while 1=1 do
begin
if Terminated then
break;
sleep(5000);
end;
在这里可能会出现一个问题。
当线程执行sleep(5000)时,那么线城会在execute方法中停留5秒,而在这5秒内,我把dll释放了。5秒后线程退出execute方法,但是这时候已经找不到该方法了,所以会出问题,应该用什么办法解决啊。
HANDLE hHandle,
DWORD dwMilliseconds
);Parameters
hHandle
[in] Handle to the object. For a list of the object types whose handles can be specified, see the following Res section.
If this handle is closed while the wait is still pending, the function's behavior is undefined.The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.dwMilliseconds
[in] Time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
HANDLE hHandle,
DWORD dwMilliseconds
);是个好的方案.
[in] Time-out interval