using System.Diagnostics; using System.IO; using System.Windows; using Zerolauncher.Manager; namespace Zerolauncher { /// /// Interaction logic for App.xaml /// 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"); } } }