title: Creating a task wrapper around an existing object
body: <p>I have a method which returns a Task where the implementation may or may not need to perform a slow operation in order to retrieve the result.  I would like to be able to simply wrap the result value into a Task which is marked as having completed synchronously in the case where the value is already available.  Today I have something like this:</p>
  
  <pre><code>public Task&lt;Foo&gt; GetFooAsync(int key) {
    lock(this) {
      if(_Cache.ContainsKey(key) ) {
        Task&lt;Foo&gt; ret = new Task&lt;Foo&gt;(()=&gt;_Cache[key]);
        ret.RunSynchronously();
        return ret;
      }
      else {
        return Task.Factory.StartNew&lt;Foo&gt;(SomethingSlow());
      }
    }
  }
  </code></pre>
  
  <p>Is there is simpler way to do this that doesn't require me to construct the task with a delegate when I already know the result?</p>