title: ReleaseMutex : Object synchronization method was called from an unsynchronized block of code
body: <p>I have this pretty straightforward piece of code that very rarely throws "System.ApplicationException : Object synchronization method was called from an unsynchronized block of code." when <strong>ReleaseMutex</strong>() is called.</p>
  
  <p>I logically analyzed the flow of the method and just cannot understand how/why this could happen. 
  To my understanding, the ownership of mutex is guaranteed in this case:</p>
  
  <pre><code>    readonly string mutexKey;
  
      public Logger(string dbServer, string dbName)
      {
          this.mutexKey = ServiceManagerHelper.GetServiceName(dbServer, dbName);
      }
  
      private void Log(LogType type, string message, Exception ex)
      {
          using (var mutex = new Mutex(false, mutexKey))
          {
              bool acquiredMutex;
              try
              {
                  acquiredMutex = mutex.WaitOne(TimeSpan.FromSeconds(5));
              }
              catch (AbandonedMutexException)
              {
                  acquiredMutex = true;
              }
  
              if (acquiredMutex)
              {
                  try
                  {
  
                      // some application code here
  
                  }
                  finally
                  {
                      mutex.ReleaseMutex();
                  }
              }
          }
      }
  </code></pre>