那TerminateThread的第二个参数怎么获取
dwExitCode
Specifies the exit code for the thread. Use the GetExitCodeThread function to retrieve a thread's exit value.
详情回复
发表于 2008-6-27 10:32
Return Value
Nonzero if it is successful; otherwise, it is zero. If the call fails, determine the cause of the failure by examining the thrown CInternetException object.
我现在使用的是你的方法2
是等待线程退出,但是怕如果这个时间太长了,
我使用过CloseHandle(m_hThread);----会导致程序退出
terminatethread能安全退出?
MSDN解释这个也是个危险操作
TerminateThread is used to cause a thread to exit. When this occurs, the target thread has no chance to execute any user-mode code and its initial stack is not deallocated. DLLs attached to the thread are not notified that the thread is terminating.
This function reduces memory leaks by clearing the stack before exiting. It also terminates the thread process only if the thread in question is the main or primary thread.
TerminateThread is a dangerous function that should only be used in the most extreme cases. You should call TerminateThread only if you know exactly what the target thread is doing, and you control all of the code that the target thread could possibly be running at the time of the termination. For example, TerminateThread can result in the following problems:
If the target thread owns a critical section, the critical section will not be released.
If the target thread is executing certain kernel32 calls when it is terminated, the kernel32 state for the thread's process could be inconsistent.
If the target thread is manipulating the global state of a shared DLL, the state of the DLL could be destroyed, affecting other users of the DLL.