C# WPF 应用程序
我通过使用在启动时显示SplashScreen的时间最短
Thread.Sleep(int); //int = milliseconds to display splash screen
当达到该睡眠时间时,代码将恢复,并且 SplashScreen 通过使用淡出关闭
SplashScreen.Close(Timespan.FromMilliseconds(int)); //int = milliseconds fade-out
我想在这一点上暂停,等到 SplashScreen 变得 100% 透明并完全关闭,然后继续其他任务,IE 写入控制台或显示 MainWindow。
(TimeSpan.FromMilliseconds(int)) 完成时是否触发了事件?还有其他建议吗?
namespace StartupSplash
{
public class SplashScreenStartup
{
//IMPORTANT:set image property to Resource and NOT Splash Screen
private SplashScreen Splash = new SplashScreen("Resources/SplashScreen.png");
public void SplashScreenStartUp()
{
Splash.Show(false, true);
Thread.Sleep(3000); // Pause code, display splash screen 3 seconds
Splash.Close(TimeSpan.FromMilliseconds(3000)); // 3 second splash fade-out
// I want to wait until splash screen fadeOut has completed before
// this next console output is performed.
Console.WriteLine("Executes before Splash fadeOut completes.");
}
}