title: Object synchronization method was called from an unsynchronized block of code. Exception on Mutex.Release()
body: <p>I have found different articles about this exception but none of them was my case.
  Here is the source code:</p>
  
  <pre><code>class Program
  {
  
      private static Mutex mutex;
      private static bool mutexIsLocked = false;
      static void Main(string[] args)
      {
  
          ICrmService crmService = 
              new ArmenianSoftware.Crm.Common.CrmServiceWrapper(GetCrmService("Armsoft", "crmserver"));
          //Lock mutex for concurrent access to workflow
          mutex = new Mutex(true, "ArmenianSoftware.Crm.Common.FilterCtiCallLogActivity");
          mutexIsLocked = true;
  
          //Create object for updating filtered cti call log
          ArmenianSoftware.Crm.Common.FilterCtiCallLog filterCtiCallLog =
              new ArmenianSoftware.Crm.Common.FilterCtiCallLog(crmService);
          //Bind events
          filterCtiCallLog.CtiCallsRetrieved += new EventHandler&lt;ArmenianSoftware.Crm.Common.CtiCallsRetrievedEventArgs&gt;(filterCtiCallLog_CtiCallsRetrieved);
  
          //Execute filter
          try
          {
              filterCtiCallLog.CreateFilteredCtiCallLogSync();
          }
          catch (Exception ex)
          {
              throw ex;
          }
          finally
          {
              if (mutexIsLocked)
              {
                  mutexIsLocked = false;
                  mutex.ReleaseMutex();
              }
          }
      }
  
      static void filterCtiCallLog_CtiCallsRetrieved(object sender,
           ArmenianSoftware.Crm.Common.CtiCallsRetrievedEventArgs e)
      {
          tryasasas
          {
              if (mutexIsLocked)
              {
                  mutexIsLocked = false;
                  mutex.ReleaseMutex();
              }
          }
          catch (Exception ex)
          {
              throw ex;
          }
      }
  }
  </code></pre>
  
  <p><code>filterCtiCallLog.CreateFilteredCtiCallLogSync();</code> function executes requests to server, and raises some events, one of which is <code>CtiCallsRetrieve</code> event. And I need to release the mutex when this event is fired. But on calling the mutex.Release() function exception is thrown.  <code>CreateFilteredCtiCallLogSync</code> works synchronously. What is the problem?</p>