我正在创建 WPF 项目,我有两个屏幕
1)载入画面
2)主窗口
我的代码如下加载屏幕
private void Window_Loaded(object sender, RoutedEventArgs e)
{
loadingThread = new Thread(load);
loadingThread.SetApartmentState(ApartmentState.STA);
loadingThread.Start();
}
private void load()
{
Thread.Sleep(1000);
this.Dispatcher.Invoke(showDelegate, "Loading UI...");
Thread.Sleep(2000);
//do some loading work
this.Dispatcher.Invoke(hideDelegate);
Thread.Sleep(2000);
this.Dispatcher.Invoke(DispatcherPriority.Normal,
(Action)delegate() { this.CLose(); });
MainWindow Mw = new MainWindow();//Gives me the error
Mw.ShowDialog();
}
当我调用我的主窗口屏幕时,我收到错误“应用程序对象正在关闭”。我相信,因为线程正在关闭,我收到了错误,谁能告诉我调用我的主窗口的其他可能方法是什么
谢谢你们