private void UIThreadDipatcherLoop()
{
Debug.WriteLine("Starting AA Wings UI thread.");
// Set the UI culture for WPF correctly
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof (FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
_dispatcher = Dispatcher.CurrentDispatcher;
Context = new DispatcherSynchronizationContext(_dispatcher);
_dispatcher.UnhandledException += UnhandledException;
SynchronizationContext.SetSynchronizationContext(Context);
// Ensure that the view models are created on the UI thread or it'll barf later
_uiReady.Set();
Dispatcher.Run();
Debug.WriteLine("AA Wings UI thread has exited.");
}