Tag: abandonedmutexexception

如何优雅地摆脱AbandonedMutexException?

我使用以下代码来同步多个正在运行的进程之间对共享资源的互斥访问。 互斥锁是这样创建的: Mutex mtx = new Mutex(false, “MyNamedMutexName”); 然后我用这个方法进入互斥部分: public bool enterMutuallyExclusiveSection() { //RETURN: ‘true’ if entered OK, // can continue with mutually exclusive section bool bRes; try { bRes = mtx.WaitOne(); } catch (AbandonedMutexException) { //Abandoned mutex, how to handle it? //bRes = ? } catch { //Some other error bRes = false; } […]