title: How can I merge two Linq IEnumerable<T> queries without running them?
body: <p>How do I merge a <code>List&lt;T&gt;</code> of TPL-based tasks for later execution?</p>
  
  <pre><code> public async IEnumerable&lt;Task&lt;string&gt;&gt; CreateTasks(){ /* stuff*/ }
  </code></pre>
  
  <p>My assumption is <a href="http://msdn.microsoft.com/en-us/library/bb882641.aspx" rel="nofollow"><code>.Concat()</code></a> ...</p>
  
  <pre><code>     void MainTestApp()  // Full sample available upon request.
       {
          List&lt;string&gt; nothingList = new List&lt;string&gt;();
          nothingList.Add("whatever");
          cts = new CancellationTokenSource();
  
           delayedExecution =
              from str in nothingList
              select AccessTheWebAsync("", cts.Token);
           delayedExecution2 =
            from str in nothingList
            select AccessTheWebAsync("1", cts.Token);
  
           delayedExecution = delayedExecution.Concat(delayedExecution2);
       }
  
  
      /// SNIP
  
      async Task AccessTheWebAsync(string nothing, CancellationToken ct)
      {
          // return a Task
      }
  </code></pre>
  
  <p>I want to make sure that this won't spawn any task or evaluate anything.  In fact, I suppose I'm asking "what logically executes an IQueryable to something that returns data"?</p>
  
  <p><strong>Background</strong></p>
  
  <p>Since I'm doing recursion and I don't want to execute this until the correct time, what is the correct way to merge the results if called multiple times?</p>
  
  <p>If it matters I'm thinking of running this command to launch all the tasks <code>var AllRunningDataTasks = results.ToList();</code> followed by this code:</p>
  
  <pre><code>while (AllRunningDataTasks.Count &gt; 0)
  {
      // Identify the first task that completes.
      Task&lt;TableResult&gt; firstFinishedTask = await Task.WhenAny(AllRunningDataTasks);
  
      // ***Remove the selected task from the list so that you don't
      // process it more than once.
      AllRunningDataTasks.Remove(firstFinishedTask);
  
      // TODO: Await the completed task.
      var taskOfTableResult = await firstFinishedTask;
  
      // Todo: (doen't work)
      TrustState thisState = (TrustState)firstFinishedTask.AsyncState;
  
      // TODO: Update the concurrent dictionary with data
      // thisState.QueryStartPoint + thisState.ThingToSearchFor 
  
      Interlocked.Decrement(ref thisState.RunningDirectQueries);
      Interlocked.Increment(ref thisState.CompletedDirectQueries);
  
      if (thisState.RunningDirectQueries == 0)
      {
          thisState.TimeCompleted = DateTime.UtcNow;
      }
  }
  </code></pre>