From dc6907bc792a28e2cdf596335db41dfa941d22cb Mon Sep 17 00:00:00 2001 From: Alex Macocian Date: Wed, 14 May 2025 12:45:14 +0200 Subject: [PATCH] Make ApplicationStarting asynchronous --- WpfExtended.Test/TestApplication/Launcher.cs | 5 ++--- WpfExtended/Launch/ExtendedApplication.cs | 6 +++--- WpfExtended/WpfExtended.csproj | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/WpfExtended.Test/TestApplication/Launcher.cs b/WpfExtended.Test/TestApplication/Launcher.cs index 20248ff..508e81b 100644 --- a/WpfExtended.Test/TestApplication/Launcher.cs +++ b/WpfExtended.Test/TestApplication/Launcher.cs @@ -7,6 +7,7 @@ using System; using System.Extensions; using System.Logging; using System.Net.Http; +using System.Threading.Tasks; using System.Windows.Extensions; using WpfExtended.Test; 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) { diff --git a/WpfExtended/Launch/ExtendedApplication.cs b/WpfExtended/Launch/ExtendedApplication.cs index 813255b..347ac7e 100644 --- a/WpfExtended/Launch/ExtendedApplication.cs +++ b/WpfExtended/Launch/ExtendedApplication.cs @@ -44,7 +44,7 @@ namespace System.Windows.Extensions /// /// Called right before the window is shown. /// - protected abstract void ApplicationStarting(); + protected abstract ValueTask ApplicationStarting(); /// /// Called right before the application is closing. /// @@ -86,9 +86,9 @@ namespace System.Windows.Extensions this.ApplicationClosing(); } - private void LaunchWindow() + private async void LaunchWindow() { - this.ApplicationStarting(); + await this.ApplicationStarting().ConfigureAwait(true); foreach(var service in this.ServiceProvider.GetServices()) { service.OnStartup(); diff --git a/WpfExtended/WpfExtended.csproj b/WpfExtended/WpfExtended.csproj index 5e5dab0..9737b27 100644 --- a/WpfExtended/WpfExtended.csproj +++ b/WpfExtended/WpfExtended.csproj @@ -6,7 +6,7 @@ true true License.txt - 0.7.8 + 0.7.9 latest Extension library for Windows Presentation Platform.