diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs index 8ac07d114d..06a5eea2b2 100644 --- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs @@ -536,7 +536,7 @@ private async Task DetectIPRange() { IsSubnetDetectionRunning = true; - var localIP = await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(IPAddress.Parse("1.1.1.1")); + var localIP = await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(IPAddress.Parse(GlobalStaticConfiguration.Dashboard_PublicIPv4Address)); // Could not detect local ip address if (localIP != null) @@ -716,7 +716,9 @@ public void OnClose() private void HostScanned(object sender, IPScannerHostScannedArgs e) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, - new Action(delegate { Results.Add(e.Args); })); + new Action(delegate { + Results.Add(e.Args); + })); } /// @@ -736,14 +738,19 @@ private void ProgressChanged(object sender, ProgressChangedArgs e) /// The instance containing the event data. private void ScanComplete(object sender, EventArgs e) { - if (Results.Count == 0) + // Run in UI thread with lower priority than HostScanned event + // to ensure all results are added first #3285 + Application.Current.Dispatcher.Invoke(() => { - StatusMessage = Strings.NoReachableHostsFound; - IsStatusMessageDisplayed = true; - } + if (Results.Count == 0) + { + StatusMessage = Strings.NoReachableHostsFound; + IsStatusMessageDisplayed = true; + } - IsCanceling = false; - IsRunning = false; + IsCanceling = false; + IsRunning = false; + }, DispatcherPriority.Background); } /// diff --git a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs index 0143f57e31..2f0ca76e10 100644 --- a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs @@ -565,14 +565,19 @@ private void ProgressChanged(object sender, ProgressChangedArgs e) private void ScanComplete(object sender, EventArgs e) { - if (Results.Count == 0) + // Run in UI thread with lower priority than PortScanned event + // to ensure all results are added first #3285 + Application.Current.Dispatcher.Invoke(() => { - StatusMessage = Strings.NoOpenPortsFound; - IsStatusMessageDisplayed = true; - } + if (Results.Count == 0) + { + StatusMessage = Strings.NoOpenPortsFound; + IsStatusMessageDisplayed = true; + } - IsCanceling = false; - IsRunning = false; + IsCanceling = false; + IsRunning = false; + }, DispatcherPriority.Background); } private void UserHasCanceled(object sender, EventArgs e) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index ba441a511c..064d8ffefe 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -84,6 +84,14 @@ Release date: **xx.xx.2025** ## Bug Fixes +**IP Scanner** + +- Fix race condition when scan is complete but not all results have been processed yet, causing a wrong error message to be displayed. [#3287](https://github.com/BornToBeRoot/NETworkManager/pull/3287) + +**Port Scanner** + +- Fix race condition when scan is complete but not all results have been processed yet, causing a wrong error message to be displayed. [#3287](https://github.com/BornToBeRoot/NETworkManager/pull/3287) + **PowerShell** - Resolve the actual path to `pwsh.exe` under `C:\Program Files\WindowsApps\` instead of relying on the stub located at `%LocalAppData%\Microsoft\WindowsApps\`. The stub simply redirects to the real executable, and settings such as themes are applied only to the real binary via the registry. [#3246](https://github.com/BornToBeRoot/NETworkManager/pull/3246)