I was wondering if, when calling Dispatcher.Invoke, the calling thread would wait until the dispatcher finished its operation or not...?
For example:
new Thread(() =>
{
string x = "Yes.";
// Invoke the dispatcher.
Dispatcher.Invoke((Action)delegate()
{
// Get the string off a UI element which contains the text, "No."
x = textBox.Text;
});
// Is x either ("Yes" or "No") here, or always "No"?
}).Start();
Seems like it will block :)
Have a look here: Dispatcher.Invoke from a new thread is locking my UI
Here's some more wisdom:
Invoke is synchronous and BeginInvoke is asynchronous. The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With