title: Usage of Mutex in c#
body: <p>I am a bit new in threading in <strong>c#</strong> and on general,
  in my program I am using <code>mutex</code> to allow only 1 thread getting inside a critical section and for unknown reason with doing some cw prints I can see that more than 1 thread is getting inside my critical section and this is my code : </p>
  
  <pre><code>Mutex m = new Mutex();
  m.WaitOne();
  &lt;C.S&gt; // critical section here
  m.ReleaseMutex();
  </code></pre>
  
  <p>I would very much like to know if I am doing a mistake here thanks in advance for your kind help.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>My code include classes so it basically looks more like this:</p>
  
  <pre><code>public class test
  {
      private mutex m;
      public test()
      {
           m = new mutex();
      }
      public func()
      {
           m.WaitOne();
           &lt;C.S&gt; // critical section here
           m.ReleaseMutex();
       }
  
  
      } 
  </code></pre>