網 6。我想在應用程式啟動時在長時間操作(例如獲取資料)后顯示 MessageBox。
- 在 3.2.0 版本中,這作業正常。當應用程式啟動時,主視圖出現,然后 MessageBox 可見。
- 在 4.0.173 版本中這不起作用: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");
}
}
uj5u.com熱心網友回復:
我已經通過事件加載解決了這個問題:查看:
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");
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451757.html
標籤:C# 异步 caliburn.micro
