Make ApplicationStarting asynchronous

This commit is contained in:
2025-05-14 12:45:14 +02:00
parent c0f4b69d80
commit dc6907bc79
3 changed files with 6 additions and 7 deletions
+2 -3
View File
@@ -7,6 +7,7 @@ using System;
using System.Extensions; using System.Extensions;
using System.Logging; using System.Logging;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Extensions; using System.Windows.Extensions;
using WpfExtended.Test; using WpfExtended.Test;
using WpfExtended.Tests.Services; using WpfExtended.Tests.Services;
@@ -47,9 +48,7 @@ namespace WpfExtended.Tests
{ {
} }
protected override void ApplicationStarting() protected override ValueTask ApplicationStarting() => ValueTask.CompletedTask;
{
}
protected override bool HandleException(Exception e) protected override bool HandleException(Exception e)
{ {
+3 -3
View File
@@ -44,7 +44,7 @@ namespace System.Windows.Extensions
/// <summary> /// <summary>
/// Called right before the window is shown. /// Called right before the window is shown.
/// </summary> /// </summary>
protected abstract void ApplicationStarting(); protected abstract ValueTask ApplicationStarting();
/// <summary> /// <summary>
/// Called right before the application is closing. /// Called right before the application is closing.
/// </summary> /// </summary>
@@ -86,9 +86,9 @@ namespace System.Windows.Extensions
this.ApplicationClosing(); this.ApplicationClosing();
} }
private void LaunchWindow() private async void LaunchWindow()
{ {
this.ApplicationStarting(); await this.ApplicationStarting().ConfigureAwait(true);
foreach(var service in this.ServiceProvider.GetServices<IApplicationLifetimeService>()) foreach(var service in this.ServiceProvider.GetServices<IApplicationLifetimeService>())
{ {
service.OnStartup(); service.OnStartup();
+1 -1
View File
@@ -6,7 +6,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseFile>License.txt</PackageLicenseFile> <PackageLicenseFile>License.txt</PackageLicenseFile>
<Version>0.7.8</Version> <Version>0.7.9</Version>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Description>Extension library for Windows Presentation Platform. <Description>Extension library for Windows Presentation Platform.