thanks for your immediate reply. My question was related to WPF as you already guessed.
By "initialize the dispatcher to UIDispatcher.Current" you mean I should access this property somehow from the UI thread during initialization? Probably like this:
I cannot see how this could solve the problem. In WPF UIDispatcher.Current simply delegates to
Here is the source code I found for the Dispatcher class:
/// Returns the Dispatcher for the calling thread.
/// If there is no dispatcher available for the current thread,
/// and the thread allows a dispatcher to be auto-created, a new
/// dispatcher will be created.
/// If there is no dispatcher for the current thread, and thread
/// does not allow one to be auto-created, an exception is thrown.
public static Dispatcher CurrentDispatcher
// Find the dispatcher for this thread.
Dispatcher currentDispatcher = FromThread(Thread.CurrentThread);;
// Auto-create the dispatcher if there is no dispatcher for
// this thread (if we are allowed to).
if(currentDispatcher == null)
currentDispatcher = new Dispatcher();
I my case, this always creates a new Dispatcher for the non-UI thread.
Compare that to the implementation of the Execute class from the Calibrun Micro framework.
/// Enables easy marshalling of code to the UI thread.
public static class Execute
private static Action<Action> executor = action => action();
/// Initializes the framework using the current dispatcher.
public static void InitializeWithDispatcher()
var dispatcher = Dispatcher.CurrentDispatcher;
executor = action =>
/// Executes the action on the UI thread.
/// <param name="action">The action to execute.</param>
public static void OnUIThread(this System.Action action)
Here they capture(!) the dispatcher retrieved during initialization and use the captured(!) dispatcher inside the OnUIThread method.
I still believe there's something missing in the SimpleMvvmToolkit.