title: await Task.WhenAll vs ..select(async .. => await)
body: <p>just a quick question. We're having some misunderstanding here.</p>
  
  <p>we have:</p>
  
  <pre><code>var tasks = files.Select(async fileName =&gt; await IngestFileAsync(container, fileName));
  var results = await Task.WhenAll(tasks);
  </code></pre>
  
  <p>I say that the first line still goes concurrent, but my fellow colleague says otherwise. Besides, he says that the second <code>await</code> has no meaning, because all 
  actions are already performed.</p>
  
  <p>is this code then the same:</p>
  
  <pre><code>var tasks = files.Select(fileName =&gt; IngestFileAsync(container, fileName));
  var results = await Task.WhenAll(tasks);
  </code></pre>
  
  <p>as:</p>
  
  <pre><code>var tasks = files.Select(async fileName =&gt; await IngestFileAsync(container, fileName));
  var results = Task.WhenAll(tasks);
  </code></pre>
  
  <p>Could someone shine some extra light on this?</p>
  
  <p>cheers.</p>
  
  <p>added:
  oke, so it will run concurrent.</p>
  
  <p>However, can someone add some extra info what the difference is between these code snippets:
  <a href="https://dotnetfiddle.net/lzv2B7" rel="nofollow noreferrer">https://dotnetfiddle.net/lzv2B7</a>
  <a href="https://dotnetfiddle.net/dMusus" rel="nofollow noreferrer">https://dotnetfiddle.net/dMusus</a></p>
  
  <p>(notice line 16, <code>async</code> and <code>await</code>). Is there any difference between those 2?
  What I would expect is that <strong>with</strong> async and await it will start directly, and without, that it will start when it comes to <code>Await Task.WhenAll(tasks);</code></p>
  
  <p>added for clearity - this is my code-:</p>
  
  <pre><code>   private async Task&lt;Result&gt; IngestFilesAsync(ICloudBlobContainer container, IEnumerable&lt;string&gt; files)
      {
          _logger.LogDebug("Start IngestFilesAsync");
  
          var tasks = files.Select(fileName =&gt; IngestFileAsync(container, fileName));
          var results = await Task.WhenAll(tasks);
  
          _logger.LogDebug("All tasks completed");
  
          if (results.Any(t =&gt; t.IsFailure))
          {
              return Result.Fail(string.Join(",", results.Select(f =&gt; f.Error)));
          }
  
          return Result.Ok();
      }
  
      private async Task&lt;Result&gt; IngestFileAsync(ICloudBlobContainer container, string fileName)
      {
          _logger.LogDebug("Start IngestFileAsync");
          var blob = container.GetBlockBlobReference(fileName);
  
          _logger.LogDebug("Blob retrieved");
  
          if (await blob.ExistsAsync())
          {
              using (var memoryStream = new MemoryStream())
              {
                  _logger.LogDebug("Start download to stream");
                  await blob.DownloadToStreamAsync(memoryStream);
                  _logger.LogDebug("To mem downloaded");
  
                  _logger.LogDebug("Start ftp-upload");
  
                  return await _targetFTP.UploadAsync(memoryStream, fileName);
              }
          }
  
          _logger.LogWarning("Blob does not exists");
  
          return Result.Fail($"Blob '{fileName}' does not exist");
      }
  </code></pre>
  
  <p>where <code>_targetFTP.UploadAsync(memoryStream, fileName);</code> is again a task etc. etc.</p>