it looks like this: the whole threading part in mvvmlight is the class:
public static class DispatcherHelper
{
public static Dispatcher UIDispatcher
{
get;
private set;
}
public static void CheckBeginInvokeOnUI(Action action)
{
if (UIDispatcher.CheckAccess())
{
action();
}
else
{
UIDispatcher.BeginInvoke(action);
}
}
public static void Initialize()
{
if (UIDispatcher != null)
{
return;
}
UIDispatcher = Deployment.Current.Dispatcher;
}
}
}
and that’s it. Use DispatcherHelper.Initialize () according to the comment in the static constructor of the application constructor (wpf) or the Application_Startup event handler (Silverlight), and then you can use DispatcherHelper.CheckBeginInvokeOnUI (action)
Hi
agend source
share