title: C# Thread safe fast(est) counter
body: <p>What is the way to obtain a thread safe counter in C# with best possible performance?</p>
  
  <p>This is as simple as it gets:</p>
  
  <pre><code>public static long GetNextValue()
  {
      long result;
      lock (LOCK)
      {
          result = COUNTER++;
      }
      return result;
  }
  </code></pre>
  
  <p>But are there faster alternatives?</p>