我的申请有问题。我在 App.xaml 中选择了 Loadscreen.xaml 作为“StartupUri”。Loadscreen.xaml.cs 包含一个进度条,运行到 100% - 然后它会关闭并打开 MainWindow。问题是,它在关闭 Loadscreen 后会打开 MainWindow 两次。我的谬误是什么?
应用程序.xaml:
StartupUri="Loadscreen.xaml"
Startup="Application_Startup">
加载屏幕.xaml.cs:
public void Timer_Tick(object sender, EventArgs e)
{
progressBar_Ladebalken.Value = i;
label_Titel.Content = i + "%";
Mouse.OverrideCursor = Cursors.Wait;
if (i < 100)
{
i += 1;
}
else
{
i = 0;
Mouse.OverrideCursor = null;
Timer.Stop();
Window W = new MainWindow();
W.Show();
this.Close();
}
公共无效应用程序_启动:
public void Application_Startup(object sender, StartupEventArgs e)
{
bool Absicherung;
Mutex Mutex = new Mutex(true, this.GetType().GUID.ToString(), out Absicherung);
if (Absicherung)
{
Window W = new Loadscreen();
W.Closed += (sender2, args) => Mutex.Close(); ;
W.Show();
}
else
{
MessageBox.Show(FM_Mutex_Meldung, FM_Mutex_Titelleiste, MessageBoxButton.OK, MessageBoxImage.Information);
Mutex.Close();
Application.Current.Shutdown();
}
}