ZeroLauncher/App.xaml.cs
2024-03-18 22:59:51 +08:00

66 lines
1.7 KiB
C#

using System.Diagnostics;
using System.IO;
using System.Windows;
using Zerolauncher.Manager;
namespace Zerolauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static bool needUpdate = false;
static bool TryDeleteDirectory(string path, bool recursive)
{
try
{
Directory.Delete(path, recursive);
return true;
}
catch (IOException)
{
return false;
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
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;
}
}
Task.Run(async () =>
{
await CloundMananger.TakeQMessage();
UpDateManager.DoCheckUpdate();
if (UpDateManager.state)
{
UpDateManager.DoUpdate();
}
});
DataStream.Load();
_ = WebApiManager.StartListener();
AccountManager.initLoadData(); }
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
WebApiManager.StopListener();
if (needUpdate) Process.Start("./cache/upacket.bin");
}
}
}