In my GUI, I launch a script (in the background hidden) that downloads a file from an FTP server. The GUI checks the progress of the download and updates a progress bar. This is working well. I wanted to slow down the amount of times that the GUI updates the progress bar so I put a Start-Sleep 60 at the bottom of the loop so that it only updates the progress bar once per minute instead of continuously (continuously would cause the GUI to "Not Responding") . This works very well. However, when the system is "sleeping" for that minute, I am unable to move, resize, or close the GUI window. The GUI becomes unresponsive during this time.
Is there a way I can accomplish what I am trying to do without the GUI becoming unresponsive?
Thanks.
Start-Sleep makes GUI unresponsive
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Start-Sleep makes GUI unresponsive
Thanks. I would love to do that, but not sure the way I am updating the progress bar is setup to do that. Could I do that looking at the below code?
while (($JobName.state -eq "running").count -gt 0)
{
$i = 0
foreach ($record in $WWCO)
{
$record1 = $record.name
try { $Percent = Get-Content "c:\Program Files (x86)\Citrix\ITM HelpDesk\FTP\$record1.xva.count" -ErrorAction SilentlyContinue } catch { }
if ($cent = $groupbox1.Controls.Find("progressbaroverlay$i", $false)) { $cent[0].Value = $Percent}
$i++
}
Start-Sleep 60
}
while (($JobName.state -eq "running").count -gt 0)
{
$i = 0
foreach ($record in $WWCO)
{
$record1 = $record.name
try { $Percent = Get-Content "c:\Program Files (x86)\Citrix\ITM HelpDesk\FTP\$record1.xva.count" -ErrorAction SilentlyContinue } catch { }
if ($cent = $groupbox1.Controls.Find("progressbaroverlay$i", $false)) { $cent[0].Value = $Percent}
$i++
}
Start-Sleep 60
}
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Start-Sleep makes GUI unresponsive
Think about what start-sleep does when you run it in the shell. Can you run other commands while it is sleeping?
look in the toolbox, second tab (square with dots) and you find a couple items you can use for this.
look in the toolbox, second tab (square with dots) and you find a couple items you can use for this.