Neither of these work:
_uiDispatcher.Invoke(() => { });
_uiDispatcher.Invoke(delegate() { });
All I want to do is Invoke an inline method on my main UI thread. So I called this on the main thread:
_uiDispatcher = Dispatcher.CurrentDispatcher;
And now I want to execute some code on that thread from another thread. How do I do it? Am I using the wrong syntax?
Note that this is not a WPF application; I've referenced WindowsBase
so I could get access to the Dispatcher
class.
_uiDispatcher
? Did you use the UI's synchronized object? – TereusuiDispatcher
is an instance of msdn.microsoft.com/en-us/library/…. I thought that was implicit from_uiDispatcher = Dispatcher.CurrentDispatcher
. "The UI" doesn't have a synchronized object AFAIK....but how would I use it? What would do that do for me? – Eserine