title: How to invoke a list of Task<T> by using Parallel
body: <p>I've got a list of async calls that are lined up in specific order and it does not matter which one finishes first or last. All of these async Task returns Bitmaps. All of the async Task return a single Bitmap accept for one and it returns a list of Bitmaps List.</p>
  
  <p>For testing purposes and me being able to get a better handle on the difference of using Parallel vs just Task I need someone to show me how to invoke each one of these async Task and set a local variable that contains a list of all the returned async results.</p>
  
  <ol>
  <li>How to Parallel.ForEach of these task</li>
  <li>How to retrieve the value of each completed task and set a local variable with the returned result.</li>
  </ol>
  
  <p>---Code where I just await each Task one after another.</p>
  
  <pre><code>public async static Task&lt;PdfSharp.Pdf.PdfDocument&gt; RollUpDrawingsPDF(IElevation elevation)
  {
  
      List&lt;Bitmap&gt; allSheets = new List&lt;Bitmap&gt;();
  
      var processedParts = new PartsProcessor.PartProcessor().ProcessParts(elevation);
  
      //elevation
      allSheets.Add(await ShopDrawing.Manager.GetElevationDrawing(elevation, true, RotateFlipType.Rotate90FlipNone));
  
      //door schedules, 3 schedules per sheet
      allSheets.AddRange(await ShopDrawing.Door.GetDoorSecheduleSheets(elevation, RotateFlipType.Rotate90FlipNone, 3));
  
      //materials list
      allSheets.Add(await MaterialsList.Manager.GetMaterialList(processedParts).GetDrawing());
  
      //optimized parts
      allSheets.Add(await Optimization.Manager.GetOptimizedParts(processedParts).GetDrawing());
  
      //cut sheet
      allSheets.Add(await CutSheet.Manager.GetCutSheet(processedParts).GetDrawing());
  
      return await PDFMaker.PDFManager.GetPDF(allSheets, true);
  }
  </code></pre>
  
  <p>------<strong>Code I'm tring to run in Parallel.ForEach however this isn't working but a starting place for help. For each returned task result I need to set the local variable of allSheets of that Parallel Task Result.</strong></p>
  
  <pre><code>    public async static Task&lt;PdfSharp.Pdf.PdfDocument&gt; RollUpDrawingsPDF(IElevation elevation)
  {
  
      List&lt;Bitmap&gt; allSheets = new List&lt;Bitmap&gt;();
  
      var processedParts = new PartsProcessor.PartProcessor().ProcessParts(elevation);
  
      Task[] myTask = new Task[5];
      myTask[0] = ShopDrawing.Manager.GetElevationDrawing(elevation, true, RotateFlipType.Rotate90FlipNone);
      myTask[1] = ShopDrawing.Door.GetDoorSecheduleSheets(elevation, RotateFlipType.Rotate90FlipNone, 3);
      myTask[2] = MaterialsList.Manager.GetMaterialList(processedParts).GetDrawing();
      myTask[3] = Optimization.Manager.GetOptimizedParts(processedParts).GetDrawing();
      myTask[4] = CutSheet.Manager.GetCutSheet(processedParts).GetDrawing();
  
  
  
      var x = Parallel.ForEach(myTask, t =&gt; t.Wait());
  
      ////elevation
      //allSheets.Add(await );
  
      ////door schedules, 3 schedules per sheet
      //allSheets.AddRange(await);
  
      ////materials list
      //allSheets.Add(await );
  
      ////optimized parts
      //allSheets.Add(await );
  
      ////cut sheet
      //allSheets.Add(await );
  
      return await PDFMaker.PDFManager.GetPDF(allSheets, true);
  }
  </code></pre>
  
  <p><strong>How would I implement the Parallel.ForEach for this body of code?</strong></p>
  
  <p>*<strong><em>Discussion code example. How to return a List when other methods return one Bitmap</em>*</strong></p>
  
  <pre><code>async Task&lt;Bitmap[]&gt; RollUpHelper(IElevation elevation, PartsProcessor.ProcessedParts       processedParts)
              {
                  return await Task&lt;Bitmap[]&gt;.WhenAll(
  
   ShopDrawing.Manager.GetElevationDrawing(elevation, true, RotateFlipType.Rotate90FlipNone),
                       //ShopDrawing.Door.GetDoorSecheduleSheets(elevation,RotateFlipType.Rotate90FlipNone, 3),
                       MaterialsList.Manager.GetMaterialList(processedParts).GetDrawing(),
                       MaterialsList.Manager.GetMaterialList(processedParts).GetDrawing(),
                       CutSheet.Manager.GetCutSheet(processedParts).GetDrawing()
                        );
  
              }
  </code></pre>