mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-04 11:15:18 +08:00
simplify OnStartup method
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<Application x:Class="BetterGenshinImpact.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Exit="OnExit"
|
||||
Startup="OnStartup">
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -112,16 +112,14 @@ public partial class App : Application
|
||||
/// <summary>
|
||||
/// Occurs when the application is loading.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the application is closing.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user