Load Form before executing code in the script

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 2 years and 11 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.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Load Form before executing code in the script

Post by GHIsolierung »

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.172
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18363.0
PowerShell version(s): 5.1.18362

I keep noticing that the code inside a graphical application is executed before the application window is displayed.

In my particular case I want to display computer information in a new (child) window.
The logic of the background job that gets these information is in the child form.
When I try to open the childform from the mainform, i would expect the childform to open and then
start the job. But the behaviour seems to be different here, the job executes instantly and slows down the opening of
the child form as long as the background job is done.

I probably just lack the programming background here, that's why I'm asking the pros.
Thank you very much for your help.

Please see attached picture.
GH Toolbox Version 1.0 2021-04-22 13.18.10.png
GH Toolbox Version 1.0 2021-04-22 13.18.10.png (58.25 KiB) Viewed 3812 times
Form 2021-04-22 13.19.16.png
Form 2021-04-22 13.19.16.png (24.52 KiB) Viewed 3812 times
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Load Form before executing code in the script

Post by brittneyr »

Without seeing any code, I can only make guesses. If you want code to happen at a specific time, please make sure all code is an an event handler. In your case, starting your job after the form is loaded might be a good idea if its affecting performance. In the childform, try starting the job in the Shown event as this event is only raised the first time a form is displayed.
Brittney
SAPIEN Technologies, Inc.
This topic is 2 years and 11 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.