title: Parallel Task Queue with return value
body: <p>I have an implementation question centered around queuing long-running tasks that return a value. Because of the CPU usage in this task, I want to limit the number of tasks running at the same time to a constant number.</p>
  
  <p>I'm returning an async task to the caller that it will await on, and hopefully the implementation will still let that happen.</p>
  
  <p>This is the task that I would like to queue, and let the caller wait on:</p>
  
  <pre><code>public async Task&lt;string&gt; LongTask(string filename)
  {
      return await Task.Run(() =&gt;
      {
          //does something for awhile
          return "my result";
      });
  }
  </code></pre>
  
  <p>This is how it is called from the caller, which will wait on the result:</p>
  
  <pre><code>string result = await LongTask("test");
  </code></pre>
  
  <p>Thanks in advance.</p>