application is already running the dispatcher
*Note: The referenced sample is no longer available as of 2013. A new Multithreaded Web Browser Sample shows a similar technique and code. The first issue – the created thread will run continuously until the application shuts down, given the code in the sample. The problem is that the ThreadStart delegate used ends with running the Dispatcher. However, nothing ever stops the Dispatcher processing. However, there are rare times when creating a separate, dedicated thread for a Window can be beneficial. This is even acknowledged in the MSDN samples, such as the Multiple Windows, Multiple Threads* sample. However, doing this correctly is difficult. Typically, in an MVVM Light application, the DispatcherHelper is initialized in App.xaml.cs, which is the file defining the startup class of the application. In Windows Phone, you call Dispatcher­Helper.Initialize in the InitializePhoneApplication method, right after the application’s main frame is created. One final thing on dispatcher class is that a given application can have only one instance of dispatcher class( as the application runs on single thread) , so Dispatcher class implements the very famous “Singleton” pattern. Because of that its impossible to create an instance of Dispatcher class in our custom code. Run is called to start a WPF application. If you define your Application using markup, or markup and code-behind, Run will be called implicitly. However, if you define your Application using code, you will need to explicitly call Run. When Run is called, Application attaches a new Dispatcher instance to the UI thread. Next, the Dispatcher object's Run method is called, which starts a message pump to process windows messages. Finally, the Dispatcher object calls the Application object's the OnStartup method to raise the Startup event. A good example of this trend is the Windows Runtime framework used in Windows Store apps. In these modern client applications, asynchronous operations (operations running on background threads) are very common. For instance, every file access in Windows 8 is now an asynchronous operation. As the WPF application runs , Dispatcher class accepts incoming requests and executes them one at a time. In short dispatcher is an object which receives messages and delivers it to the correct object for further processing. Dispatcher class is pretty dense with lots of properties and methods. The code above in bold accomplishes the task of shutting down the dispatcher for window’s UI thread. Running multiple UI threads in WPF application is actually rather trivial. In the nutshell it boils down to creating your dedicated thread and creating your windows inside this thread’s proc. Remember to conclude your UI thread with a call to WPF dispatcher. As the name suggests, this method performs a check first. If the caller of the method is already running on the main thread, no dispatching is necessary. In that case, the delegate is executed immediately, directly on the main thread. If, however, the caller is on a background thread, the dispatching is executed. The thread the controls the application is commonly known as UIThread. “Dispatcher” concept is a mechanism introduced in WPF , with the help of which developer can have more explicit control on this UI thread as of what executes when. We will look into this in more details in the remaining section of this article.
MVVM Light and WPF.