use Dispatcher.Invoke

This commit is contained in:
MyDrift
2024-07-13 12:54:59 +02:00
parent 790e0b22a5
commit 27792dc8a3
10 changed files with 23 additions and 20 deletions

View File

@ -23,7 +23,7 @@ function Invoke-WPFInstall {
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $DebugPreference)
Set-WinUtilTaskbaritem -state "Normal" -value 1/$PackagesToInstall.Count
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:PackagesToInstall.Count })
$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
@ -54,13 +54,13 @@ function Invoke-WPFInstall {
Write-Host "==========================================="
Write-Host "-- Installs have finished ---"
Write-Host "==========================================="
# Set-WinUtilTaskbaritem -state "None"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
}
Catch {
Write-Host "==========================================="
Write-Host "Error: $_"
Write-Host "==========================================="
# Set-WinUtilTaskbaritem -state "Error"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
}
Start-Sleep -Seconds 5
$sync.ProcessRunning = $False