I knew the basic building blocks of multithreading in WPF, but I have a question that confuses me quite a bit.
WPF applications start with two threads:
one to handle rendering, and the other to control the user interface.
Sounds good, but the user interface thread bothers me, UI Thread is nothing more than an application thread
Elements belong to the thread that creates the WPF interface element and other threads cannot directly interact with user interface elements, this is known as thread affinity.
Let's say I have two text fields and One Button in the Myapplication application, and each text field has its own DispatcherObject , when I click the button, I update the text field with the values, I hope that this will be done in the user interface stream .
1. Now, my question is this user interface thread - this is the application thread, the Button will have its own DispatcherObject and Two text fields will have their own DispatcherObject . Like this UI thread, which has its own DispatcherObject and is different from these UI controls. Can DispatcherObject update text fields?
- My question is also: if I create a new text file in the background thread, is it possible to update this text field from the user interface thread?
please correct my understanding, I could not move on.
Selva source
share