Answer the question
In order to leave comments, you need to log in
Why does WaitForSingleObject work incorrectly in DLL_PROCESS_DETACH?
I am writing a DLL.
I call the 1st function, inside it I create a thread:
hThread = CreateThread(NULL, 0, MyThreadFunction, ...);
StopMyThread(hThread); //моя фукнция
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
Answer the question
In order to leave comments, you need to log in
When DLLMain is called, the system critical section is called, which is also used in functions such as: WaitForSingleObject and others. Replaced WaitForSingleObject with a self-written one - it all worked!
From the DllMain help :
Because DLL notifications are serialized, entry-point functions should not attempt to communicate with other threads or processes. Deadlocks may occur as a result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question