GUI hang when specific script engine is chosen

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI hang when specific script engine is chosen

Post by jvierra »

To clarify:

To run Azure Cmdlets without blocking in a WinForm you must place all CmdLets in a Job.

$sb = { Your azure commands }
Start-Job -ScriptBlock $sb

Build you scriptblock and test at a command prompt before running it in the form.

Test the block alone first like this:

$sb.Invoke() or $sb.Invoke( arg1, arg2, …)

Then test as a job.

To get information from the job into the form use "Receive-Job"

When necessary use the "JobTracker" custom control set to do this.
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: GUI hang when specific script engine is chosen

Post by mxtrinidad »

FYI...

In the code, I don't see where it is sent "as a job" to be run in the background. The "while" loop will not work as you probably need to do a Get-* to update the status property within the loop (and not outside).

Do you have this script working for the console? If not, I would suggest to create the console script first, and fine tune it before moving it to a GUI application.

The recent articles and blog post about background Jobs shows this method:
1. Create the console script first and make it work.
2. Then, with few more changes, move it to the GUI application.

Please feel free to post any questions, to get you going.
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: GUI hang when specific script engine is chosen

Post by mxtrinidad »

Also, I would suggest to post an issue on github Azure (https://github.com/Azure/azure-powershell/issues) asking when these cmdlets (Start/Get AzureStorageBlobCopy) are going to be included in AzureRM.

Keep in mind, everyone is moving away from Azure (Classic) Module.
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked