Why does System.Windows.Forms BeginInvoke seem to work in WPF
<p>I am kind of new to WPF. While experimenting with WPF and its threading model I tried to do some experimentation. </p>

<p>I ran the following lines of code in the <strong>MainWindow.xaml.cs</strong>.</p>

<pre><code>    var sync = SynchronizationContext.Current;
</code></pre>

<p>// returns System.Windows.Threading.DispatcherSynchronizationContext //</p>

<pre><code>    var frm = new System.Windows.Form();
    IntPtr temp = frm.Handle;
    sync = SynchronizationContext.Current;
</code></pre>

<p>// Still <strong>sync</strong> is System.Windows.Threading.DispatcherSynchronizationContext. So I kinda guessed that System.Windows.Form creates the System.Windows.Forms.WindowsFormsSynchronizationContext if SynchronizationContext.Current is null.//</p>

<p>//Now comes the weird part.</p>

<pre><code>    Thread th = new Thread(() =&gt;
                           {
                                     Action strac = UpdateTextBox;
                                     frm.BeginInvoke(strac);
                           });
    th.Start();



    void UpdateTextBox()
    {
        textBox1.Text = "Abhik";
    }
</code></pre>

<p>// I tried to use the System.Windows.Form's BeginInvoke to marshall a request back to the UI thread and updated a UI control. </p>

<p><strong>It worked!!..</strong></p>

<p>Can please anyone tell me why did it work. Is this beacuse WPF control and the winform controls share the same ancestry in windows os ie User32.dll and DispatcherSynchronizationContext and WindowsFormsSynchronizationContext does the same thing internally. </p>

<p>Any help will be appreciated.</p>
