title: Creating large amount of tasks/threads and waiting for them all to complete
body: <p>I'm writing a fairly simple Raytracer and I've run into runtime limitations because the program is single-threaded. The result I've been finding through google all answer this type of question with two or three tasks to be handled.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var taskList = new List&lt;Task&gt;();
  
          taskList.Add(Task.Factory.StartNew(() =&gt; doStuff()));
          taskList.Add(Task.Factory.StartNew(() =&gt; doStuff()));
          taskList.Add(Task.Factory.StartNew(() =&gt; doStuff()));
  
          Task.WaitAll(taskList);
  
          Console.WriteLine("All threads complete");
      }
  
      static void doStuff()
      {
          //do stuff here
      }
  }
  </code></pre>
  
  <p>I'm looking at atleast 10,000 individual threads, if implemented naively. The solution above doesn't seem like the optimal one in this scenario. Is there a part of the standard library that supports this, or is there a Nuget package that has something like this implemented? It might also just be me baing stupid, and >10,000 threads in a List is not a problem at all. Then the issue becomes when the cutoff is. I would need 12500000 tasks/threads in some instances, which I'm pretty sure is way too many for a list.</p>
  
  <p>Below is roughly how I would create a new thread/task as it stands now.</p>
  
  <pre><code>for (var x = 0; x &lt; image.Width; x++) {
      for (var y = 0; y &lt; image.Height; y++) {
          var coordinates = new Vector3(x, y, 0);
          var task = new Task(() =&gt; {
              RenderSinglePixel(coordinates);
          });
      }
  }
  </code></pre>