This question already has an answer here:
这个问题在这里已有答案:
- Is it wrong to use the Dispatcher within my ViewModel? 3 answers
- 在我的ViewModel中使用Dispatcher是错误的吗? 3个答案
There is a background thread in the viewmodel. It is trying to set a usercontrol property there which is being binded to the view. In simpler terms, accessing a UI thread from a non UI thread. What are the ways to establish this?
viewmodel中有一个后台线程。它正在尝试在那里设置一个绑定到视图的usercontrol属性。简单来说,从非UI线程访问UI线程。有什么办法来建立这个?
Thanks in advance.
提前致谢。
1 个解决方案
#1
0
in WPF:
在WPF中:
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background, () => { /* UI WORK HERE */ });
#1
0
in WPF:
在WPF中:
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background, () => { /* UI WORK HERE */ });