title: Locking on a collection, then creating a new instance of the collection. Dangerous?
body: <p>I'm currently working on a multi-threaded interface for a few hardware devices, and I was storing my polling packet in a List collection. Since this interface needs to be very thread safe, I've taken to locking the collection every time I want to make changes to it. I've found through running diagnostics that creating a new instance of the collection is much faster than clearing it and then adding a new range of values for the poll. I was wanting to know if doing this though would cause issues with the locking, as I have limited experience with multi-threading applications and even less experience locking on a collection rather than a SyncRoot object. </p>
  
  <p>Here's an example snippet for comparison:</p>
  
  <pre><code>lock (Poll)
  {
      Poll = new List&lt;byte&gt;(new byte[] { START, 0x00, STATUS_REQUEST, 0x00, 0x00});
  }
  </code></pre>
  
  <p>Versus....</p>
  
  <pre><code>lock (Poll)
  {
      Poll.Clear();
      Poll.AddRange(new byte[] { START, ZERO, STATUS_REQUEST, ZERO, ZERO });
  }
  </code></pre>
  
  <p>Edit: Wanted to note that the Poll object is not publicly exposed. That's a no-no. </p>