title: Should a return statement be inside or outside a lock?
body: <p>I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?</p>
  
  <p>1)</p>
  
  <pre><code>void example()
  {
      lock (mutex)
      {
      //...
      }
      return myData;
  }
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>void example()
  {
      lock (mutex)
      {
      //...
      return myData;
      }
  
  }
  </code></pre>
  
  <p>Which one should I use?</p>