好像您正在阻止 UI 线程,请以这种方式尝试:
public partial class App
{
#region Methods
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var splashScreenService = ServiceLocator.Default.ResolveType<ISplashScreenService>();
splashScreenService.Enqueue(new ActionTask("Task1", tracker => Thread.Sleep(2000)));
splashScreenService.Enqueue(new ActionTask("Task2", tracker => Thread.Sleep(2000)));
splashScreenService.Enqueue(new ActionTask("Task3", tracker => Thread.Sleep(2000)));
splashScreenService.CommitAsync();
}
#endregion
}
或为您的自定义启动画面
public partial class App
{
#region Methods
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var splashScreenService = ServiceLocator.Default.ResolveType<ISplashScreenService>();
splashScreenService.Enqueue(new ActionTask("Task1", tracker => Thread.Sleep(2000)));
splashScreenService.Enqueue(new ActionTask("Task2", tracker => Thread.Sleep(2000)));
splashScreenService.Enqueue(new ActionTask("Task3", tracker => Thread.Sleep(2000)));
splashScreenService.CommitAsync<SplashScreenViewModel>();
}
#endregion
}