Reputation: 12872
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();
Upvotes: 5
Views: 6401
Reputation: 11763
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.
Upvotes: 9