【发布时间】:2013-11-14 02:13:57
【问题描述】:
我想知道,在调用 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();
【问题讨论】:
-
你为什么不试试呢?在调用中添加几秒钟的睡眠,在其中添加另一行,并查看它是否在完成之前击中它...
-
@Noctis 你知道吗,我现在太累了......我什至没有想到,但我想我会试一试。不过,让某人参考一些有形的文档不会有什么坏处:P
-
没有什么比在小时候编码更重要的了,嗯?
-
不......刚刚为你回答了你的问题......它回到了你的代码矿!
标签: c# .net wpf multithreading dispatcher