Domanda

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();
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top