From e06e7c878ccc4375fcbfa84676fd89249a01fa20 Mon Sep 17 00:00:00 2001 From: ema Date: Sun, 26 Nov 2023 02:13:30 +0800 Subject: [PATCH] simplify OnStartup method --- BetterGenshinImpact/App.xaml | 4 +--- BetterGenshinImpact/App.xaml.cs | 21 +++++++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/BetterGenshinImpact/App.xaml b/BetterGenshinImpact/App.xaml index 051f55de..96835942 100644 --- a/BetterGenshinImpact/App.xaml +++ b/BetterGenshinImpact/App.xaml @@ -1,9 +1,7 @@  + xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"> diff --git a/BetterGenshinImpact/App.xaml.cs b/BetterGenshinImpact/App.xaml.cs index 73a420ed..2d562ca9 100644 --- a/BetterGenshinImpact/App.xaml.cs +++ b/BetterGenshinImpact/App.xaml.cs @@ -112,16 +112,14 @@ public partial class App : Application /// /// Occurs when the application is loading. /// - private void OnStartup(object sender, StartupEventArgs e) + protected override async void OnStartup(StartupEventArgs e) { - StartUp(); - } + base.OnStartup(e); - private async void StartUp() - { try { - await StartUpCoreAsync(); + RegisterEvents(); + await _host.StartAsync(); await UrlProtocolHelper.RegisterAsync(); } catch (Exception ex) @@ -136,19 +134,14 @@ public partial class App : Application } } - private async Task StartUpCoreAsync() - { - RegisterEvents(); - await _host.StartAsync(); - } - /// /// Occurs when the application is closing. /// - private async void OnExit(object sender, ExitEventArgs e) + protected override async void OnExit(ExitEventArgs e) { - await _host.StopAsync(); + base.OnExit(e); + await _host.StopAsync(); _host.Dispose(); }