ZeroLauncher/App.xaml.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2024-03-18 22:59:51 +08:00
using System.Diagnostics;
using System.IO;
using System.Windows;
2024-03-07 21:04:59 +08:00
using Zerolauncher.Manager;
namespace Zerolauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
2024-03-18 22:59:51 +08:00
public static bool needUpdate = false;
static bool TryDeleteDirectory(string path, bool recursive)
{
try
{
Directory.Delete(path, recursive);
return true;
}
catch (IOException)
{
return false;
}
}
2024-03-07 21:04:59 +08:00
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
2024-03-18 22:59:51 +08:00
if (e.Args.Length == 1)
{
switch (e.Args[0])
{
case "updateDone":
{
for (int i = 0; i < 3 && !TryDeleteDirectory(@"./cache", true); i++)
Thread.Sleep(3000);
}
break;
}
}
2024-03-11 10:57:12 +08:00
Task.Run(async () =>
2024-03-09 18:29:16 +08:00
{
2024-03-11 10:57:12 +08:00
await CloundMananger.TakeQMessage();
UpDateManager.DoCheckUpdate();
2024-03-18 22:59:51 +08:00
if (UpDateManager.state)
2024-03-11 10:57:12 +08:00
{
2024-03-18 22:59:51 +08:00
UpDateManager.DoUpdate();
2024-03-11 10:57:12 +08:00
}
});
DataStream.Load();
_ = WebApiManager.StartListener();
AccountManager.initLoadData(); }
2024-03-09 18:29:16 +08:00
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
WebApiManager.StopListener();
2024-03-18 22:59:51 +08:00
if (needUpdate) Process.Start("./cache/upacket.bin");
2024-03-07 21:04:59 +08:00
}
}
}