我有一部分代码开始创建(用一会儿的话)30个作业(最多),但是Windows窗体被阻止等待所有“ while”(也许是2000个)的完成,并且我想使其响应。我该怎么办?
谢谢:)
while ($subred -ne ($subredmax + 1))
{
while ($ip1 -ne ($ip2 + 1))
{
$linea = [System.Text.StringBuilder]''
$linea.Append("172.20.") | Out-Null
$linea.Append($subred) | Out-Null
$linea.Append(".") | Out-Null
$linea.Append($ip1) | Out-Null
if ($ExcArray.Contains([string]$linea))
{
[void]$ProgressBar1.Increment(1)
}
else
{
while (@(get-job).Count -gt 30)
{
Get-Job | Wait-Job -Any
$(Get-Job -State 'Completed') | Remove-Job
}
$aux = $linea, $subred, $path
Start-Job -Name "JobJob" $miprom -ArgumentList $aux
[void]$ProgressBar1.Increment(1)
}
$ip1++
}
$subred++
$ip1 = 50
}
Get-Job | Wait-Job
Get-Job | Remove-Job
$logs = New-Object System.Collections.ArrayList
Exception-To-Array -array $logs -path $path\etc\log.txt
Array-ToTB -tb $Show_Info -array $logs