title: How to return T value from BeginInvoke?
body: <p>I want to write a class to simplify the asynchronous programing, like string s = mylib.BeginInvoek(test,"1"); here is my code:</p>
  
  <pre><code>   public T BeginInvokeExWithReturnValue&lt;T&gt;(Func&lt;T&gt; actionFunction)
      {
          ExecWithReturnType&lt;T&gt; execWtihReturnValue = new ExecWithReturnType&lt;T&gt;(actionFunction);
          IAsyncResult iar = execWtihReturnValue.BeginInvoke(new AsyncCallback(EndInvokeExWithReturnValue&lt;T&gt;), execWtihReturnValue);
          // how to code here to return value
      }
  
      private void EndInvokeExWithReturnValue&lt;T&gt;(IAsyncResult iar)
      {
          ExecWithReturnType&lt;T&gt; execWtihReturnValue = (ExecWithReturnType&lt;T&gt;)iar.AsyncState;
          execWtihReturnValue.EndInvoke(iar);
      }
  </code></pre>
  
  <p>this BeginInvokeExWithReturnValue function has no input parameter, but returns a value, 
  But I don't know how to return a value from BeginInvokeExWithReturnValue function. Anyone who know this, Could you pls help me ? thx very much.</p>