Skip to content

Feature: Remove ThreadPool workaround and make scanner async - #3564

Open
BornToBeRoot wants to merge 3 commits into
mainfrom
chore/improve-scanner
Open

Feature: Remove ThreadPool workaround and make scanner async#3564
BornToBeRoot wants to merge 3 commits into
mainfrom
chore/improve-scanner

Conversation

@BornToBeRoot

Copy link
Copy Markdown
Owner

Changes proposed in this pull request

  • Remove ThreadPool workaround
  • Make scanner async

To-Do

Contributing

By submitting this pull request, I confirm the following:

Copilot AI balanced review requested due to automatic review settings August 5, 2026 19:27
@github-actions github-actions Bot added this to the next-release milestone Aug 5, 2026
@mergify

mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cancellation regressions, abandoned NetBIOS receive tasks, and the missing promised changelog entry need correction.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Removes the ThreadPool workaround and modernizes scanner operations with asynchronous network APIs.

Changes:

  • Removes ThreadPool configuration from settings, UI, localization, and documentation.
  • Converts host, port, ping, DNS, and NetBIOS scanning paths to async.
  • Updates scanner defaults and introduces a shared TCP port probe.
File summaries
File Description
Website/docs/settings/general.md Removes ThreadPool documentation.
Website/docs/application/port-scanner.md Updates concurrency documentation.
Website/docs/application/ip-scanner.md Updates ports and concurrency defaults.
Source/NETworkManager/Views/SettingsGeneralView.xaml Removes ThreadPool setting UI.
Source/NETworkManager/Views/PortScannerSettingsView.xaml Removes obsolete ThreadPool notice.
Source/NETworkManager/Views/IPScannerSettingsView.xaml Removes obsolete ThreadPool notice.
Source/NETworkManager/ViewModels/SettingsGeneralViewModel.cs Removes ThreadPool setting binding.
Source/NETworkManager/App.xaml.cs Removes ThreadPool startup configuration.
Source/NETworkManager.Settings/SettingsInfo.cs Removes persisted ThreadPool setting.
Source/NETworkManager.Settings/GlobalStaticConfiguration.cs Updates scanner defaults.
Source/NETworkManager.Models/Network/PortScanner.cs Makes port scanning asynchronous.
Source/NETworkManager.Models/Network/PortProbe.cs Adds shared asynchronous TCP probing.
Source/NETworkManager.Models/Network/NetBIOSResolver.cs Makes receive timeout asynchronous.
Source/NETworkManager.Models/Network/IPScanner.cs Converts scanner operations to async.
Source/NETworkManager.Models/Network/HostRangeHelper.cs Makes hostname resolution asynchronous.
Source/NETworkManager.Localization/Resources/Strings.resx Removes obsolete localized strings.
Source/NETworkManager.Localization/Resources/Strings.Designer.cs Removes generated resource accessors.
Review details

Files not reviewed (1)

  • Source/NETworkManager.Localization/Resources/Strings.Designer.cs: Generated file

Suppressed comments (1)

Source/NETworkManager.Models/Network/HostRangeHelper.cs:163

  • The hostname-with-subnet branch also stops honoring cancellation while DNS is pending. Since this helper may perform both A and AAAA queries, Stop can remain stuck in preparation until all lookup timeout/retry work completes. Make the await token-aware.
                    var dnsResultWithSubnet = await DNSClientHelper.ResolveAorAaaaAsync(hostAndSubnet[0], true)
                        .ConfigureAwait(false);
  • Files reviewed: 17/18 changed files
  • Comments generated: 5
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +140 to +141
var dnsResult = await DNSClient.GetInstance().ResolvePtrAsync(host.ipAddress)
.ConfigureAwait(false);
Comment on lines +92 to +93
var dnsResult = await DNSClient.GetInstance().ResolvePtrAsync(host.ipAddress)
.ConfigureAwait(false);
Comment on lines +146 to +147
var dnsResult = await DNSClientHelper.ResolveAorAaaaAsync(host, dnsResolveHostnamePreferIPv4)
.ConfigureAwait(false);
Comment on lines 58 to 64
var receiveTask = udpClient.ReceiveAsync();
var timeoutTask = Task.Delay(timeout, cancellationToken);

if (!receiveTask.Wait(timeout, cancellationToken))
var completedTask = await Task.WhenAny(receiveTask, timeoutTask).ConfigureAwait(false);

if (completedTask == timeoutTask)
return new NetBIOSInfo(ipAddress);
Comment on lines +3 to +4
description: "Configure which applications appear in the NETworkManager sidebar and adjust general application behavior."
keywords: [NETworkManager, general settings, sidebar configuration, application settings]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Existing settings omit the new default ports, and concurrent cancellation can incorrectly fault TCP probes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Files not reviewed (1)

  • Source/NETworkManager.Localization/Resources/Strings.Designer.cs: Generated file

Suppressed comments (2)

Source/NETworkManager.Models/Network/PortProbe.cs:47

  • The general exception filter makes normal connect failures escape whenever user cancellation happens concurrently. For example, a SocketException from a refused connection is no longer mapped to Closed if the token was canceled just before the catch executes; it faults the fire-and-forget scan, and the scanners only report OperationCanceledException as cancellation. Re-throw cancellation exceptions explicitly, but continue classifying every non-cancellation connect failure as Closed.
        catch (Exception) when (!cancellationToken.IsCancellationRequested)
        {
            // Connection refused, host unreachable, etc.
            return PortState.Closed;

Source/NETworkManager.Settings/SettingsManager.cs:773

  • Existing installations that still have the old default port list never receive the newly defaulted ports. Changing GlobalStaticConfiguration only affects newly created settings; this upgrade migrates the old concurrency defaults but omits the analogous IPScanner_PortScanPorts migration, so upgraded users continue scanning without ports 135 and 9100. Migrate the value only when it exactly matches the old default, preserving customized lists.
        // Add new Port Scanner port profiles
  • Files reviewed: 23/24 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants