issue with GUI Freezing

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 8 years and 4 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
User avatar
sam.wrighton
Posts: 14
Last visit: Tue Sep 27, 2016 4:42 am

issue with GUI Freezing

Post by sam.wrighton »

Hi all

im still new to Powershell scripting on this level so I know my code is not great but im having a big issue with the GUI freezing. when I run the code in powershell studio the GUI works fine and updated the progress bars and debug log, but ive just tested it after I built it to a .exe and the GUI is freezing when I deploy VMs and the GUI doesn't update until the VM is deployed (when it exits the while loop). please can someone help with my coding if there is a better way to do what im trying to do then please let me know what that is.

many thanks in advance
Last edited by sam.wrighton on Thu Nov 12, 2015 12:18 am, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: issue with GUI Freezing

Post by jvierra »

Hi Sam. A couple of suggestions. TO post a project you need to zip the whole project folder. There are files missing from you post that are necessary for running you project.

To understand how to prevent a form from freezing see the following: https://www.sapien.com/blog/?s=responsive+forms
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: issue with GUI Freezing

Post by jvierra »

I took a quick look at you code. It is 8000+ lines of linear code. There is no way we can understand what this code is doing in a forum environment. You need to isolate the code in question and post that snippet that is causing the issues.

I can make a couple of suggestions that you can think about for future projects.

1. Consider learning a bit about the basics of program design.
2. Think about how to use a single function to replace repeated copies of code.
3. Controls and tabs can be generated dynamically at run time.
4. Successful programs are based on a well defined data model used for describing and storing the programs data.

The current forms program could be greatly simplified but it would probably not be worth it if it is currently working.

Your project, if well designed, would likely be less that 500 lines of code.

For this program just isolate the event that is causing you the freezing. You can just reference it by event name.
User avatar
sam.wrighton
Posts: 14
Last visit: Tue Sep 27, 2016 4:42 am

Re: issue with GUI Freezing

Post by sam.wrighton »

Hi

thanks for the reply ive attached the whole project in this post

I understand my code is far from perfect but this is what I understand at this moment in time. if you or anyone could help further I would be very thankful
Last edited by sam.wrighton on Thu Nov 12, 2015 12:18 am, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: issue with GUI Freezing

Post by jvierra »

In this case the project does little good. What we need is the event that is causing the freeze.'
User avatar
sam.wrighton
Posts: 14
Last visit: Tue Sep 27, 2016 4:42 am

Re: issue with GUI Freezing

Post by sam.wrighton »

hi

I my 1st post I said that when it is deploy VMs it is freezing In the while loop

Globals.ps1 line 19951 is the 1st loop

there are while loops in the
Deploy-2ndBatch
Deploy-3rdBatch
Deploy-4thBatch
functions
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: issue with GUI Freezing

Post by jvierra »

Not much we can do about the design but you can place the function in a job and monitor the job with a timer. To find out how to do this see the links I posted above.
User avatar
sam.wrighton
Posts: 14
Last visit: Tue Sep 27, 2016 4:42 am

Re: issue with GUI Freezing

Post by sam.wrighton »

hi

I looked at jobs but this wont give me the VMware task it, it will give me the job ID so I wont be able to check vCenter if the deploy has been successful
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: issue with GUI Freezing

Post by jvierra »

Jobs will do exactly what you need but you will have to redesign your forms to run more independently.

Sorry but there is no simple solution. Try running your script as a PS file with no forms and launching it from the form. Dump the configuration to an XML file that the script can read.

Adjusting the script to use correct programming rules would allow you to run the function in a job. Read the blog posts to learn how to do this.
This topic is 8 years and 4 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