启动画面计时器 [英] Splash Screen Timer
问题描述
我实际上尝试向我的 WPF 应用程序添加启动画面.很简单:
I actually try to add a Splash Screen to my WPF application. It is quite easy:
SplashScreen s = new SplashScreen("/Images/Agrar.png");
s.Show(true);
我的问题是,我希望启动画面显示大约 10 秒,但我的应用程序不需要那么长时间来加载.
My problem is, that I want the Splash Screen to show about 10sec, but my Application doesn´t need so long to load.
所以我想到了 Timer 类并尝试了一些,但我不知道如何将它与启动画面结合起来.有更好的解决方案吗?它如何与定时器一起工作?因为我没有找到一个选项来说明计时器运行时应该发生什么.
So I thought about the Timer class and tried a bit, but I don´t know how to combine it with a Splash Screen. Is there a better solution? How does it work with Timer? Because I didn´t find a option to say, what should happen while the Timer is running.
推荐答案
你可以尝试让你的主线程休眠 10 秒(如果飞溅可见,用户无论如何都不会使用你的应用),或者淡出飞溅在一段时间内:
You can try putting your main thread to sleep for 10 seconds (if splash is visible, users won't use your app anyway), or fade out the splash over a period of time:
SplashScreen splash = new SplashScreen("/Images/Agrar.png");
splash.Show(false);
Thread.Sleep(10000);
splash.Close( TimeSpan.FromSeconds(20)); //fade out over 20 seconds
这篇关于启动画面计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!