title: How to store a Task in a dictionary for later execution in C#
body: <p>I'm trying to store a Task in a dictionary for later execution with no success:</p>
  
  <pre><code>Dictionary&lt;string, Task&lt;object&gt;&gt; router = new Dictionary&lt;string, Task&lt;object&gt;();
  router["xyz"] = functionToLaterExec
  
  async Task&lt;string&gt; functionToLaterExec()
  {
      return await Task.FromResult("Success!");
  } 
  </code></pre>
  
  <p>If I declare the function as </p>
  
  <pre><code>string functionToExec()
  </code></pre>
  
  <p>Then I can do:</p>
  
  <pre><code>router["xyz"] = new Task&lt;string&gt;(functionToExec);
  </code></pre>
  
  <p>But I need the function to be async. And don't know how to invoke it. I've tryed:</p>
  
  <pre><code>var t = router["xyz"];
  var data = Encoding.UTF8.GetBytes(await t);
  </code></pre>
  
  <p>with no success.</p>
  
  <p>Thanks.</p>