How can I lock in just one place
<p>I have two threads and a <code>Queue&lt;string&gt;</code>. The first thread doing some performance critical work in a loop and it checks the <code>Queue&lt;string&gt;</code> each iteration, grabbing the string if <code>Queue</code> is not empty.</p>

<p>Now I need the second thread to <em>safely</em> put strings in a <code>Queue</code>. Only the second thread should <strong>wait</strong> when the 1st thread isn't doing anything with the <code>Queue</code>. I don't want to use <code>lock</code> because it will be blocking the 1st thread eventually slowing it down.</p>

<p>How can I do that? I tried to surround only <code>Enqueue()</code> in my 2nd thread with the lock statement, but the ReSharper is warning me that:</p>

<blockquote>
  <p>the field is sometimes used inside synchronized block and sometimes used without synchronization.</p>
</blockquote>

<p>So I guess I'm not doing it right.</p>