title: C# Wait delegate finish before continue
body: <p>I need to access a DataGridView control from a a thread other than the thread it was created on. I read I must use a delegate and it works, but I need to wait that delegate finishes before continue in the thread. I tried to call <code>EndInvoke</code> after <code>BeginInvoke</code>, but the thread continues.</p>
  
  <pre><code>public void ArrangeGrid()
  {
      ArrangeGridHandler ag = ArrangeGridAsync;
      IAsyncResult result = ag.BeginInvoke(cb, null);
      ag.EndInvoke(result);
  }
  </code></pre>
  
  <p>When I call <code>ArrangeGrid()</code> the thread continues even if it isn't finished.  How can I do?
  Thanks!</p>