Splash Screen Timer

99封情书 提交于 2019-12-13 01:06:54

问题


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);

My problem is, that I want the Splash Screen to show about 10sec, but my Application doesn´t need so long to load.

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.


回答1:


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



回答2:


The best way and using the API is

  SplashScreen splash = new SplashScreen("splashscreen.jpg");
  splash.Show(false);
  splash.Close(TimeSpan.FromMilliseconds(2));
  InitializeComponent();


来源:https://stackoverflow.com/questions/9279769/splash-screen-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!