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

@ -10,7 +10,7 @@ function Invoke-WinUtilFeatureInstall {
$CheckBox
)
Set-WinUtilTaskbaritem -state "Normal" -value 1
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:CheckBox.Count })
$CheckBox | ForEach-Object {
if($sync.configs.feature.$psitem.feature){
@ -39,6 +39,7 @@ function Invoke-WinUtilFeatureInstall {
Write-Host "Running Script for $psitem"
Invoke-Command $scriptblock -ErrorAction stop
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
}
Catch{
if ($psitem.Exception.Message -like "*requires elevation*"){
@ -46,7 +47,7 @@ function Invoke-WinUtilFeatureInstall {
}
else{
Set-WinUtilTaskbaritem -state "Error"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
Write-Warning "Unable to Install $feature due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
@ -54,7 +55,4 @@ function Invoke-WinUtilFeatureInstall {
}
}
}
if ($sync["Form"].taskbarItemInfo.ProgressState -ne "Error"){
Set-WinUtilTaskbaritem -state "None"
}
}