I have an init method in which I create a thread and a window is displayed This is my application code
public static SplashWindow _splashWindow;
private static ManualResetEvent ResetSplashCreated;
private static Thread SplashThread;
public static void Init(SplashWindow splashWindow)
{
_splashWindow = splashWindow;
ResetSplashCreated = new ManualResetEvent(false);
SplashThread = new Thread(() => ShowSplash(_splashWindow));
SplashThread.SetApartmentState(ApartmentState.STA);
SplashThread.IsBackground = true;
SplashThread.Name = "Splash Screen";
SplashThread.Start();
ResetSplashCreated.WaitOne();
}
public static void ShowSplash(SplashWindow splash)
{
splash.Show();
ResetSplashCreated.Set();
System.Windows.Threading.Dispatcher.Run();
}
now when i call this code:
SplashHelper.Init(new anim());
I get an error in the splash.show();
line
System.InvalidOperationException: 'The calling thread cannot access this object because a different thread owns it.'