Take a look at the
SmartDispatcher class that John Papa has created.
Source: John Papa's Blog
Sometimes your code runs on a background thread, for example, and you need to do something to the UI. But you are on the background thread and can’t affect the UI from there, so what do you do? You use the Dispatcher (or SynchronizationContext class) to help you get back to the UI thread. There are several ways to do this, but the most common one I use is via a SmartDispatcher class I created recently.