mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
chore: 提取UntilIdleAsync函数
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MaaWpfGui.States
|
||||
{
|
||||
@@ -48,5 +49,13 @@ namespace MaaWpfGui.States
|
||||
{
|
||||
IdleChanged?.Invoke(this, newIdleValue);
|
||||
}
|
||||
|
||||
public async Task UntilIdleAsync(int time = 1000)
|
||||
{
|
||||
while (!GetIdle())
|
||||
{
|
||||
await Task.Delay(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,22 +585,16 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
public void AskToRestart()
|
||||
public async void AskToRestart()
|
||||
{
|
||||
if (Instances.SettingsViewModel.AutoInstallUpdatePackage)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
while (!runningState.GetIdle())
|
||||
{
|
||||
await Task.Delay(60000);
|
||||
}
|
||||
await runningState.UntilIdleAsync(60000);
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
Bootstrapper.RestartApplication();
|
||||
});
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
Bootstrapper.RestartApplication();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user