Getting WPF Dispatcher from library
Is there a way to get the GUI D开发者_如何学编程ispatcher from a library without passing reference from the GUI?
I'm working with a library (MVVM) that can invalidate datasources which will cause a GUI update. The Invalidate call needs to come from the GUI thread. I can just pass the reference, but it would be nice not to have to do that.
The GUI dispatcher for the library will be the same dispatcher for your application. Anything that needs to run on the UI thread can just be called with Application.Current.Dispatcher
.
Application.Current.Dispatcher
精彩评论