C#WPF应用程序
我通过使用在启动时显示SplashScreen最少的时间
Thread.Sleep(int); //int = milliseconds to display splash screen
Run Code Online (Sandbox Code Playgroud)
达到该睡眠时间后,代码将恢复,并且SplashScreen将逐渐淡出以关闭
SplashScreen.Close(Timespan.FromMilliseconds(int)); //int = milliseconds fade-out
Run Code Online (Sandbox Code Playgroud)
我想在此时暂停等待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 …Run Code Online (Sandbox Code Playgroud) 我试图在c#中执行此任务.
我有2个整数... int TotalScore int ExtraLife
每当TotalScore增加至少5时,我想将"ExtraLife"增加1?
这是一个例子......
public void Example(int scored)
{
TotalScore += scored;
if (TotalScore > 0 && TotalScore % 5 == 0)
{
ExtraLife++;
// it seems that the ExtraLife will only increment if the
// total score is a multiple of 5.
// So if the TotalScore were 4 and 2 were passed
// in as the argument, the ExtraLife will not increment.
}
}
Run Code Online (Sandbox Code Playgroud)