我想知道,在调用 Dispatcher.Invoke 时,调用线程是否会等到调度程序完成其操作...?
例如:
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();
最佳答案
好像会阻塞:)
看看这里:Dispatcher.Invoke from a new thread is locking my UI
这里还有一些智慧:
Invoke is synchronous and BeginInvoke is asynchronous. The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
关于c# - Dispatcher.Invoke 是否在调用线程上阻塞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19968253/