title: Is this use of Parallel.ForEach() thread safe?
body: <p>Essentially, I am working with this:</p>
  
  <pre><code>var data = input.AsParallel();
  List&lt;String&gt; output = new List&lt;String&gt;();
  
  Parallel.ForEach&lt;String&gt;(data, line =&gt; {
      String outputLine = ""; 
      // ** Do something with "line" and store result in "outputLine" **
  
      // Additionally, there are some this.Invoke statements for updating UI
  
      output.Add(outputLine);
  });
  </code></pre>
  
  <p>Input is a <code>List&lt;String&gt;</code> object. The <code>ForEach()</code> statement does some processing on each value, updates the UI, and adds the result to the <code>output</code> <code>List</code>. Is there anything inherently wrong with this? </p>
  
  <p><strong>Notes:</strong></p>
  
  <ul>
  <li>Output order is <strong>unimportant</strong></li>
  </ul>
  
  <p><strong>Update:</strong></p>
  
  <p>Based on feedback I've gotten, I've added a manual <code>lock</code> to the <code>output.Add</code> statement, as well as to the UI updating code.</p>