title: C++/CX: Using Dispatcher to access UI thread doesn't work
body: <p>I am working on a UWP application and need to use TextBlock class in non-UI code. Attempting to instantiate TextBlock object produces "RPC_E_WRONG_THREAD (The application called an interface that was marshalled for a different thread)" exception.
  From the information I have gathered on the Internet I understand that I should execute my code in the UI thread. I used the following code:</p>
  
  <pre><code>CoreDispatcher^ dispatcher = CoreWindow::GetForCurrentThread()-&gt;Dispatcher;
  
  dispatcher-&gt;RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler
                                                              [/* captured variables */]() {
      TextBlock ^text_block = ref new TextBlock();
      /* other code */
  });
  </code></pre>
  
  <p>The problem is, I recieve the same exception the moment TextBlock instantiation is attempted. What am i doing wrong?</p>
  
  <p><strong>UPD</strong>:
  I've just realized that the project I'm working on is a DirectX UWP App. Does it mean that it can't access UI thread directly?</p>