title: C# Return value from function invoked in thread
body: <p>I have a calculating thread function which invokes message function from other thread using Invoke and I want that calculating thread to get value(of valuetype, like integer) from that message function. How can I do this? </p>
  
  <p>The problem is that I still get old value of x variable after Invoke(...) and I expect value of 15</p>
  
  <pre><code>delegate void mes_del(object param);
  
  void MyThreadFunc()
  {
  ...
  int x = 5;
  object [] parms = new object []{x};
  Invoke(new mes_del(MessageFunc), (object)parms);
  ...
  }
  
  void MessageFunc(object result)
  {
     int res = 15;
     (result as object[])[0] = res;
  }
  </code></pre>
  
  <p>I tried some approaches like using object[], object as parameters with no success. I though boxing/unboxing operations should occur in such a case but they don't.
  Should I use auxiliary type like it is done in .NET event mode and create mediator object like
  class holder
  {
  public int x;
  }</p>