I am trying to prevent the form from freezing/unresponsive when the $output can't connect to remote computer. I need to set the timer to release the event back to the form.
$button1.Enabled = $false
$TotalTime = 10 #in seconds
$script:StartTime = (Get-Date).AddSeconds($TotalTime)
#Start the timer
$timerUpdate.Start()
[TimeSpan]$span = $script:StartTime - (Get-Date)
if ($span.TotalSeconds -le 0)
{
$timerUpdate.Stop()
}
$output = ssh user1@$remotecomputer
$button1.Enabled = $true
Prevent Script from Freezing PS Studio 2019 form
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: Prevent Script from Freezing PS Studio 2019 form
Events cannot be terminated. If a call blocks in an event you will just have to wait for completion or for a timeout. If it deadlocks then it is likely due to some system failure although third party software may not be well designed and may not prevent a complet4e freeze.
You can run scripts in a job and then kill the job if it hangs.
See: https://info.sapien.com/index.php/guis/ ... sive-forms
You can run scripts in a job and then kill the job if it hangs.
See: https://info.sapien.com/index.php/guis/ ... sive-forms