title: Modifying list of related objects asynchronously yields unexpected results
body: <p>I have a list of objects which can have one or more relationships to one another. I'd like to run through this list and compare each object to all other objects in the list, setting the relationships as I compare the objects. Because this comparison in real life is fairly complex and time consuming I'm trying to do this asynchronously.</p>
  
  <p>I've quickly put together some sample code which illustrates the issue at hand in a fairly simple fashion. </p>
  
  <pre><code>class Program
      {
          private static readonly Word[] _words =
          {
              new Word("Beef"),
              new Word("Bull"),
              new Word("Space")
          };
  
          static void Main()
          {
              var tasks = new List&lt;Task&gt;();
  
              foreach (var word in _words)
              {
                  tasks.Add(CheckRelationShipsAsnc(word));
              }
  
              Task.WhenAll(tasks);
          }
  
          static async Task CheckRelationShipsAsnc(Word leftWord)
          {
              await Task.Run(() =&gt;
              {
                  foreach (var rightWord in _words)
                  {
                      if(leftWord.Text.First() == rightWord.Text.First())
                      {
                          leftWord.RelationShips.Add(rightWord);
                      }
                  }
              });
          }
      }
  
      class Word
      {
          public string Text { get; }
          public List&lt;Word&gt; RelationShips { get; } = new List&lt;Word&gt;();
  
          public Word(string text)
          {
              if(string.IsNullOrEmpty(text)) throw new ArgumentException();
              Text = text;
          }
  
          public override string ToString()
          {
              return $"{Text} ({RelationShips.Count} relationships)";
          }
      }
  </code></pre>
  
  <p>The expected result would be that "Space" has no relationships whereas the words "Bull" and "Beef" have one relationship to one another. What I get is all words have no relationsships at all. I'm having trouble understanding what exactly the problem is. </p>