Search code examples
visual-c++uwpuwp-xamlwindowsiotwindows-iot-core-10

How to access UI from thread in C++ UWP App?


I have a native C++ multi-threaded console application. I ported this application into UWP app with minimal change/ now I want to print out text into textbox in UI as there is no console app available in UWP app.

For this, I required access to a text box from a thread.


Solution

  • This is about asynchronous programming in C++.You can refer to this article.It describes the recommended way to consume asynchronous methods in Visual C++ and managing the thread context.You can populate text box within task::then method.On other hand, you can also use DispatchedHandler to access UI,please see this sample.