title: How do I collect return values from Parallel.ForEach?
body: <p>I'm calling a slow webservice in parallel. Things were great until I realized I need to get some information back from the service. But I don't see where to get the values back. I can't write to the database, HttpContext.Current appears to be null inside of a method called using Parallel.ForEach</p>
  
  <p>Below is a sample program (in your mind, please imagine a slow web service instead of a string concatenation)</p>
  
  <pre><code>using System;
  using System.Threading.Tasks;
  
  class Program
  {
      static void Main(string[] args)
      {
          WordMaker m = new WordMaker();
          m.MakeIt();
      }
      public class WordMaker
      {
          public void MakeIt()
          {
              string[] words = { "ack", "ook" };
              ParallelLoopResult result = Parallel.ForEach(words, word =&gt; AddB(word));
              Console.WriteLine("Where did my results go?");
              Console.ReadKey();
          }
          public string AddB(string word)
          {
              return "b" + word;
          }
      }
  
  }
  </code></pre>