Hosting WPF in separate C++ thread <p>Need to substitute old GUI engine with WPF in a C++ library. I don't have control of the application main (implementing a DLL) meaning I don't control the threading model (In contrast to <a href="http://msdn.microsoft.com/en-us/library/ms744829(v=vs.110).aspx" rel="nofollow">Walkthrough: Hosting WPF Content in Win32</a>). Since WPF requires STA I understand I need to launch a separate thread for it like so:</p> <pre><code>Thread^ t = gcnew Thread(gcnew ThreadStart(this, &amp;ThreadClass::ThreadEntryPoint)); t-&gt;SetApartmentState(ApartmentState::STA); t-&gt;Start(); ThreadEntryPoint() { App^ app = gcnew App(); Window^ w = gcnew Window(); app-&gt;Run(w); } </code></pre> <p>Back in native the old GUI engine does so which is similar to what MFC would do:</p> <pre><code>Create dialog/window d; d-&gt;SomeLabel-&gt;Caption = "abc"; d-&gt;ComboBox-&gt;Add(item); etc... d-&gt;ShowDialog(); // at which point control passes to user </code></pre> <p>and:</p> <pre><code>DialogClass:OnButtonPress() { SomeLabel-&gt;Caption = "xyz"; } </code></pre> <p>a. Ideally I would like to be able to use such simple instructions (Control.property = x) for WPF but since it's in a separate thread it's not possible, is it?</p> <p>b. In order to be able to manipulate GUI controls before the window appears I did Sleep(Infinite) after gcnew Window() but before app->Run(w) and Interupt()ed the main thread. I used this example that gets a property (how to change field value?):</p> <pre><code>Type^ t = w-&gt;label1-&gt;GetType(); Object^ o = w-&gt;label1; DispatcherObject ^dispObj = (DispatcherObject^)(o); PropertyInfo ^propertyInfo = t-&gt;GetProperty( "Name" ); Object^ result = dispObj-&gt;Dispatcher-&gt;Invoke(gcnew Func&lt;Object^,array&lt;Object^&gt;^, Object^&gt;(propertyInfo, &amp;PropertyInfo::GetValue), dispObj); </code></pre> <p>which failed amongst other reasons because the WPF thread was in sleep. Of course I can implement a whole Sleep/Interrupt mechanism for each property I set but it seems bad design.</p> <p>My question, assuming WPF is the way to go, what is the correct way to implement? </p>