Caliburn 如何在应用程序启动时加载数据?

Caliburn how to load data when app is starting?

Net6. 我想在应用程序启动时在长时间操作(例如获取数据)后显示 MessageBox。

我的代码:

Caliburn.Micro 3.2.0
    internal class ShellViewModel : Screen
    {
        protected override async void OnInitialize()
        {
            base.OnInitialize();
            await Task.Delay(1000);
            System.Windows.MessageBox.Show("hello");
        }
    }
    
Caliburn.Micro 4.0.173
    internal class ShellViewModel : Screen
    {
        protected override async Task OnInitializeAsync(CancellationToken cancellationToken)
        {
            await base.OnInitializeAsync(cancellationToken);
            await Task.Delay(1000);
            System.Windows.MessageBox.Show("hello");
        }
    }

我已经通过加载事件解决了这个问题: 查看:

xmlns:cal="http://caliburnmicro.com"
cal:Message.Attach="[Event Loaded] = [Action Window_Loaded()]"

虚拟机:

    public async Task Window_Loaded()
    {
        await Task.Delay(1000);
        System.Windows.MessageBox.Show("hello");
    }