好的,我只是想创建一个基本的加载页面,所以我有一些性感的页面出现(不做任何加载)只是在我的真实表单出现之前出现了几秒钟
这是我的代码:
public partial class LoadingPage : Window
{
System.Threading.Thread iThread;
public LoadingPage()
{
InitializeComponent();
}
private void Refresh()
{
System.Threading.Thread.Sleep(900);
MainWindow iMain = new MainWindow();
iMain.ShowDialog();
this.Dispatcher.Invoke(new Action(Close));
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
iThread = new System.Threading.Thread(new ThreadStart(Refresh));
iThread.SetApartmentState(System.Threading.ApartmentState.STA);
iThread.Start();
}
private void Close()
{
this.Close();
}
这可行,但会导致堆栈溢出,并且在主页打开时不会关闭加载窗口..
此外,close 方法有一个绿色下划线,说明“隐藏继承的成员 System.Window.Windows.Close() 如果要隐藏,请使用新关键字”
问题是:是什么导致堆栈溢出?