The following works much better for me when used in a WinForms application that also uses WPF (in my case Esri Arcmap.exe)
private System.Windows.Threading.Dispatcher Dispatcher { get; set; } // I put this in my view model constructor as it MUST be called from UI thread Dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
Another method (which included calling new System.Windows.Application() to populate System.Windows.Application.Current ) caused problems for me every time I opened a new WPF window and then closed it. This not only excluded System.Windows.Application.Current , but I could no longer open new windows, as their InitializeComponents() methods did not work with:
System.InvalidOperationException: 'Application object is closing.'
So far, the new solution has worked without these side effects.
M Townsend Dec 10 '18 at 10:06
source share