Hello,
I am creating a WPF Window splash window to display progress for an application startup. The window calls a Thread class which is set to an STA thread so that the thread can instantiate the main application window (ex. MainWindow win = new MainWindow()) and then run various methods to gather some initial data. The window will not be displayed here though. All is well up until I need to get the instantiated "win" object from the thread and back to the splash UI thread. I am getting the typical "object can't be used because it was created in a different thread" message. I tried various things regarding a dispatcher, such as:
splash.Dispatcher.BeginInvoke(InitAppTaskComplete, new object[] { win });
The method from my splash class that gets the invoke callback gets a good Window object but if it tries to show it, I still gets the error that it was created in another thread. I have been trying countless avenues in trying to solve this (using background workers, Task delegates, etc) but I always either run into either the issue of it being created in another thread or an error that the current thread must be an STA thread to instantiate the Window object. Does anyone have any thoughts on how I might be able to accomplish this?