title: Setting properties from an object over multiple threads
body: <p>I will try my best to explain the situation.</p>
  
  <pre><code>public class A
  {
      Int64 Id { get; set; }
      Decimal Foo { get; set; }
  }
  
  public class B
  {
      Int64 Id { get; set; }
      Decimal Bar { get; set; }
  }
  
  public class C
  {
      Int64 Id { get; set; }
      Decimal? Foo { get; set; }
      Decimal? Bar { get; set; }
  }
  
  public class test
  {
      ConcurrentDictionary&lt;Int64, C&gt; dictionary { get; set; }
      List&lt;A&gt; listA { get; set; } 
      List&lt;B&gt; listB { get; set; }
  }
  </code></pre>
  
  <p>listA and listB each contain 5 million objects.</p>
  
  <p>So what I do is, I loop through listA and listB on seperate threads.
  I check if the dictionary contains the id, then get the value and set the matching property.</p>
  
  <p><b> So my question is, is this threadsafe? If not, what would be the best way to make it threadsafe </b></p>
  
  <p>One more thing :</p>
  
  <ul>
  <li>There are no duplicates in listA and listB. So I only set the property of any object C once.</li>
  </ul>
  
  <p>An example using dummy data:</p>
  
  <pre><code>List&lt;A&gt; listA = new List&lt;A&gt; 
  { 
      new A { Id = 1, Foo = 5 },
      new A { Id = 2, Foo = 10 },
      new A { Id = 3, Foo = 100 }
  };
  
  List&lt;B&gt; listB = new List&lt;B&gt; 
  { 
      new A { Id = 1, Bar = 3 },
      new A { Id = 2, Bar = 2 },
      new A { Id = 3, Bar = 1 }
  };
  
  ConcurrentDictionary&lt;Int64, C&gt; dictionary = new ConcurrentDictionary&lt;Int64, C&gt;
  {
      Keys = {1, 2, 3},
      Values = { new C { Id = 1 }, new C { Id = 2 }, new C { Id = 3 } }
  };
  </code></pre>
  
  <p>Afterwards I the dictionary would have these key/value pairs :</p>
  
  <pre><code>Key = 1 , value = object of class C with properties : Id = 1, Foo = 5, Bar = 3,
  Key = 1 , value = object of class C with properties : Id = 1, Foo = 10, Bar = 2,
  Key = 1 , value = object of class C with properties : Id = 1, Foo = 100, Bar = 1    
  </code></pre>