Feat: Add configurable thread limit for parallel operations

Adds a "Threads" setting to the UI, allowing users to control the throttle limit for parallel tasks like driver and application processing.

This introduces a new textbox in the build options and updates the parallel processing function to use this configurable value instead of a hardcoded one.

Input validation is also added to ensure the threads value is a valid integer and is at least 1. The new setting is integrated into the configuration save/load functionality.
This commit is contained in:
rbalsleyMSFT
2025-07-18 13:45:58 -07:00
parent e639cee4ee
commit 7cc7919da4
11 changed files with 119 additions and 34 deletions
@@ -21,7 +21,9 @@ function Invoke-ParallelProcessing {
[Parameter(Mandatory = $false)]
[object]$WindowObject = $null, # Changed type to [object]
[Parameter(Mandatory = $false)]
[string]$MainThreadLogPath = $null # New parameter for the log path
[string]$MainThreadLogPath = $null, # New parameter for the log path
[Parameter(Mandatory = $false)]
[int]$ThrottleLimit = 5
)
# Check if running in UI mode by verifying the types of the passed objects
$isUiMode = ($null -ne $WindowObject -and $WindowObject -is [System.Windows.Window] -and $null -ne $ListViewControl -and $ListViewControl -is [System.Windows.Controls.ListView])
@@ -287,7 +289,7 @@ function Invoke-ParallelProcessing {
DriverPath = $driverPathValue
}
} -ThrottleLimit 5 -AsJob
} -ThrottleLimit $ThrottleLimit -AsJob
}
catch {
# Catch errors during the *creation* of the parallel jobs (e.g., module loading in main thread failed)
@@ -412,7 +414,8 @@ function Invoke-ParallelProcessing {
}
}
if (-not $jobHandled) { # Catches 'Completed' with no data
if (-not $jobHandled) {
# Catches 'Completed' with no data
$finalIdentifier = "UnknownJob"
WriteLog "Job $($completedJob.Id) completed with state '$($completedJob.State)' but had no data."
$finalStatus = "$ErrorStatusPrefix No Result Data"