I am trying to get the SplashScreenService up and running. It does show my splashscreen, but it doesn't close, never.
I have this code in app.xaml.cs:
protected override void OnStartup(StartupEventArgs e)
{
ServiceLocator.Default.RegisterTypeIfNotYetRegistered<ISplashScreenService, SplashScreenService>();
var splashScreenService = ServiceLocator.Default.ResolveType<ISplashScreenService>();
splashScreenService.Enqueue(new ActionTask("Task1", tracker => Thread.Sleep(2000)));
splashScreenService.Commit<SplashScreenViewModel>();
base.OnStartup(e);
}
Can anybody help me what I am doing wrong ?
Seems like you are blocking the UI thread please try in this way:
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
}
or for your custom splash screen
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
}