Skip to content

Commit

Permalink
修复启动错误无法汇报的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
d3ara1n committed Jun 29, 2023
1 parent 31798e7 commit 54b0ec3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Polymerium.App/ViewModels/InstanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class InstanceViewModel : ObservableObject
private readonly ResolveEngine _resolver;
private readonly GameManager _gameManager;
private readonly AccountManager _accountManager;
private readonly DispatcherQueue _dispatcher;
private string coreVersion = string.Empty;

private bool isModSupported;
Expand Down Expand Up @@ -87,6 +88,7 @@ AccountManager accountManager
_notificationService = notificationService;
_gameManager = gameManager;
_accountManager = accountManager;
_dispatcher = DispatcherQueue.GetForCurrentThread();
Instance = context.AssociatedInstance!;
OverlayService = overlayService;
CoreVersion = Instance.Inner.GetCoreVersion() ?? "N/A";
Expand Down Expand Up @@ -401,12 +403,13 @@ public bool Prepare(Action<int?> callback)

private void StartAbort(string message)
{
DispatcherQueue
.GetForCurrentThread()
_dispatcher
.TryEnqueue(() =>
{
var messageBox = new MessageDialog() { Title = "挂起", Message = message };
messageBox.ShowAsync().AsTask().Wait();
var messageBox = new MessageDialog() { XamlRoot = App.Current.Window.Content.XamlRoot, Title = "挂起", Message = message };
#pragma warning disable CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
messageBox.ShowAsync();
#pragma warning restore CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
});
}

Expand Down

0 comments on commit 54b0ec3

Please sign in to comment.