mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-03 03:23:31 -05:00
use Dispatcher.Invoke
This commit is contained in:
@ -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"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user