我遇到了自定义wpf启动画面实现的问题.问题是在加载完成并且应该显示MainWindow之后,它有时不会被带到前面,即Activate()调用失败.它可能发生1/10倍.应用程序在Windows7/64上运行.
这是实施(完整源样本)
public partial class App : Application
{
private Splash _splash;
private SplashVM _viewModel;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// starts splash in separate GUI thread
StartSplash();
// continues on loading main application in main gui thread
LoadMainAppFakeSteps(1000, 3);
// tells splash screen to start shutting down
Stop();
// Creates mainwindow for application
// The problem is that the mainwindow sometimes fails to activate,
// even when user has not touched mouse or keyboard (i.e …Run Code Online (Sandbox Code Playgroud)