Should I dispose a Mutex?
问题 I'm working on 2 Windows Services that have a common database which I want to lock (cross-process) with a system Mutex. Now I'm wondering whether it's ok to just call WaitOne() and ReleaseMutex() in a try-finally block or should I also dispose the Mutex (e.g. in a using block). If so I guess I should always catch the AbandonedMutexException on the WaitOne() method or am I wrong here? 回答1: A mutex is a Windows kernel object (here wrapped in a .NET object). As such, it is an unmanaged resource