title: Control.Dispatcher.BeginInvoke() and Control.Dispatcher.Invoke() order execution is confusing?
body: <p>I'm using WPF, and I was confused about the order of execution <code>Control.Dispatcher.BeginInvoke()</code> and <code>Control.Dispatcher.Invoke()</code>.</p>
  
  <p>I will show an example of code below</p>
  
  <pre><code>backgroundThread = new Thread(BackgroundThread);
  backgroundThread.Start();
  public void BackgroundThread()
  {
      this.Dispatcher.BeginInvoke(new Action(delegate()
      {
        WriteLog("Run command 1");
      }));
  
      this.Dispatcher.Invoke(new Action(delegate()
      {
        WriteLog("Run command 2");
      }));
  }
  </code></pre>
  
  <p>I expect the "Command 1" will be run and finished before "command 2", but sometimes It seems the "Command 2" run before "Command 1". I have researched much on internet and MSDN document, but I don't understand why this happen.</p>
  
  <p>Someone please tell me the rule of these functions exactly?</p>
  
  <p>Many thanks!</p>
  
  <p>T&amp;T</p>