Golden Rule of Windows Multithreading
“Thou shalt only update UI using code that runs on the same thread as the UI.”
To obey the golden rule, the data needs to be shuttled back to the UI thread so we can update the element on the UI thread, rather than from some other thread.
In WPF, a quick, simple, and nice solution is to use the Dispatcher.
For the example, please refer to here
For the details of Dispatcher, please refer to MS official document.