Why doesn't Mutex get released when disposed?

后端 未结 9 1167
青春惊慌失措
青春惊慌失措 2020-11-29 02:22

I have the following code:

using (Mutex mut = new Mutex(false, MUTEX_NAME))
{
    if (mut.WaitOne(new TimeSpan(0, 0, 30)))
    {
       // Some code that dea         


        
9条回答
  •  一向
    一向 (楼主)
    2020-11-29 02:54

    Be aware: The Mutex.Dispose() executed by the Garbage collector fails because the garbage collection process does not own the handle according Windows.

提交回复
热议问题