if (mutex)
{
WaitForSingleObject(mutex, INFINITE);
if ( !ReleaseMutex(mutex) )
{
//Attempt to release mutex not owned by caller.
}
}
GetLastError()得到的错误信息是:Attempt to release mutex not owned by caller
请问发生这种错误的可能原因有哪些呢?
...全文
2715打赏收藏
ReleaseMutex 失败
if (mutex) { WaitForSingleObject(mutex, INFINITE); if ( !ReleaseMutex(mutex) ) { //Attempt to release mutex not owned by caller. } } GetLastError()得到的错误信息是:Attempt to release mutex not owned by caller 请问发生这种错误的可能原因有哪些呢?
这种错误出现也很正常,WaitForSingleObject返回WAIT_ABANDONED。这种情况在拥有互斥对象的线程使用ExitThread等操作的时候很可能发生,这时候执行你所贴代码的线程就不拥有mutex,那么释放的时候就会返回FALSE,调用GetLastError()返回ERROR_NOT_OWNER,错误信息(Attempt to release mutex not owned by caller)