From 8bc053053c36a25e8972b02442995821be4a63cc Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Thu, 18 Sep 2025 23:37:10 +0200 Subject: [PATCH] App: Add auto update check on network change to active --- Elwig/App.xaml.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs index afb14b5..d92c9da 100644 --- a/Elwig/App.xaml.cs +++ b/Elwig/App.xaml.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; +using System.Net.NetworkInformation; using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -131,6 +132,7 @@ namespace Elwig { await CheckForUpdates(); }); } + NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged; _autoUpdateTimer.Tick += new EventHandler(OnAutoUpdateTimer); _autoUpdateTimer.Start(); } @@ -228,6 +230,16 @@ namespace Elwig { } } + private void OnNetworkAvailabilityChanged(object? sender, NetworkAvailabilityEventArgs evt) { + if (!evt.IsAvailable) return; + if (Utils.HasInternetConnectivity()) { + Utils.RunBackground("Auto Updater", async () => { + await Task.Delay(500); + await CheckForUpdates(); + }); + } + } + public static async Task CheckForUpdates(bool showAlert = false) { if (Config.UpdateUrl == null) return; var latest = await Utils.GetLatestInstallerUrl(Config.UpdateUrl);