C# appbootstrapper.configure之前的启动屏幕

C# appbootstrapper.configure之前的启动屏幕,c#,wpf,autofac,splash-screen,caliburn.micro,C#,Wpf,Autofac,Splash Screen,Caliburn.micro,所以我到处寻找这个,但我找不到任何符合我需要的东西。我有一个WPF应用程序,我正在使用Caliburn Micro和Autofac 我的App.xaml是 <Application x:Class="Drogo.Meera.Ui.Wpf.Launcher.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schema

所以我到处寻找这个,但我找不到任何符合我需要的东西。我有一个WPF应用程序,我正在使用Caliburn Micro和Autofac

我的App.xaml是

<Application x:Class="Drogo.Meera.Ui.Wpf.Launcher.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:launcher="clr-namespace:Drogo.Meera.Ui.Wpf.Launcher">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <launcher:AppBootstrapper x:Key="AppBootstrapper"/>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

而AppBootstrapper是

public class AppBootstrapper : BootstrapperBase
{
    private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    private IContainer _container;

    public AppBootstrapper()
    {
        this._log.Debug("AppBootstrapper ctor...");
        this.Initialize();
    }

    protected override void OnStartup(object sender, StartupEventArgs e)
    {
        this._log.Debug("AppBootstrapper.OnStartup");
    }

    protected override void Configure()
    {
        this._log.Debug("ENTER:AppBootstrapper.Configure");
        try
        {
            var builder = new ContainerBuilder();

            builder.Register<IWindowManager>(c => new WindowManager()).InstancePerLifetimeScope();
            builder.Register<IEventAggregator>(c => new EventAggregator()).InstancePerLifetimeScope();

            // register all other dependencies on the builder

            this._container = builder.Build();
        }
        catch (Exception ex)
        {
            this._log.Error(ex.ToString());
        }

        this._log.Debug("EXIT:AppBootstrapper.Configure");
    }

    protected override object GetInstance(Type service, string key)
    {
    ...
    }

    protected override IEnumerable<object> GetAllInstances(Type service)
    {
    ...
    }

    protected override void BuildUp(object instance)
    {
        this._container.InjectProperties(instance);
    }
}
公共类AppBootstrapper:BootstrapperBase
{
private readonly ILog\u log=LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
私人集装箱;
公共AppBootstrapper()
{
这个.u log.Debug(“AppBootstrapper ctor…”);
这是初始化();
}
启动时受保护的覆盖无效(对象发送方、StartupEventArgs e)
{
这个.u log.Debug(“AppBootstrapper.OnStartup”);
}
受保护的覆盖无效配置()
{
这个.u log.Debug(“输入:AppBootstrapper.Configure”);
尝试
{
var builder=new ContainerBuilder();
注册(c=>newWindowManager()).InstancePerLifetimeScope();
Register(c=>neweventaggregator()).InstancePerLifetimeScope();
//在生成器上注册所有其他依赖项
这个._container=builder.Build();
}
捕获(例外情况除外)
{
此.u log.Error(例如ToString());
}
这个.u log.Debug(“EXIT:AppBootstrapper.Configure”);
}
受保护的覆盖对象GetInstance(类型服务,字符串键)
{
...
}
受保护的重写IEnumerable GetAllInstances(类型服务)
{
...
}
受保护的覆盖空洞堆积(对象实例)
{
此._container.InjectProperties(实例);
}
}
好的,所以我的应用程序运行良好(我还没有定义主窗口,这仍在进行中)。我预计,我将从引用的程序集中获得许多Autofac模块,我将在上面的
Configure
方法中加载所有依赖项,我预计这可能需要几秒钟(可能需要4-5秒或更长时间)

我希望在应用程序启动时(我对可以随进度更新的单例SplashScreen感兴趣)和执行
AppBootstrapper
之前(最好)加载一个启动屏幕

我看到过使用构建类型设置为SplashScreen的图像的例子,但这不是我想要的。我想要一个带有文本块的基于窗口的启动屏幕,该文本块可以在应用程序启动时由每个Autofac模块随进度进行更新。我也尝试过在
OnStartup
方法中创建一个启动屏幕,但是太晚了,因为这是在
Configure
之后发生的


我对WPF相当陌生,对Caliburn Micro甚至更新,但我对Autofac有很好的了解,如果有人能提出实现这一点的最佳方法,我将不胜感激。

试试这个感谢@Alex,他帮助我想出了一个可行的解决方案