Running project takes 1 minute

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.
User avatar
stevens
Posts: 416
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Wed Jun 15, 2016 2:26 am

Running project takes 1 minute

Post by stevens »

Hi,

When I launch "Run" in my Powershell Form, it take about 1 minute before it actually launches. Doesn't look that long, but it does, first thought it was broken.
Can't see anywhere why it loads that long, when I build the exe and launch that, it takes 2 seconds.

Where can I find out why the run takes this much time?

S

jvierra
Posts: 14437
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Running project takes 1 minute

Post by jvierra »

What is "launch run". What code is that. Do you mean "Start-Process" or are you trying to use the old "Shell Run" command?

User avatar
stevens
Posts: 416
Joined: Wed Jun 15, 2016 2:26 am

Re: Running project takes 1 minute

Post by stevens »

There is a green button (triangle) in the PS Studio menu (ribbon) which says 'Run', when I'm pressing that, it takes a minute for the form to load.
When I go to the Deploy tab in that same ribbon, and click build & run or Run, it loads in seconds.

jvierra
Posts: 14437
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Running project takes 1 minute

Post by jvierra »

When running from the menu the system loads the code analyzer and analyzes the code before running. With build and run the code analyzer is not run and the exe is just generated and execute. This is normal. You can turn of the code analyzer on the options page. The script analyzer should be reviewed as it will tell you where your code can be improved and gives good statistics on the script design, The default also runs the performance analyzer which also takes time to load. If your script is long and has many issues with style, structure and definition the script analyzer could take quite a while to complete the analysis and output the report.

I highly recommend posting product issues in the Sapien product support forum. They will be able to give you more current and complete answers as they work with these issues daily and are also a team that can find the best answers for product issues. This forum is mostly for questions about the technology of forms use with PowerShell.

User avatar
stevens
Posts: 416
Joined: Wed Jun 15, 2016 2:26 am

Re: Running project takes 1 minute

Post by stevens »

Thanks. Can you tell me
>You can turn of the code analyzer on the options page. The script analyzer should be reviewed
where I can turn off the code analyzer? I can't find it in the options page or is it "Enable automatic syntax checking" in Editor Settings on option page?

jvierra
Posts: 14437
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Running project takes 1 minute

Post by jvierra »

Annotation 2020-04-08 050452.png
Annotation 2020-04-08 050452.png (17.62 KiB) Viewed 605 times

User avatar
stevens
Posts: 416
Joined: Wed Jun 15, 2016 2:26 am

Re: Running project takes 1 minute

Post by stevens »

Thanks, but disabling that didn't help. Still takes long time (little bit less now).
I do think it was a setting I changed though. One day it was working fine (started in seconds), next day it takes a minute.

jvierra
Posts: 14437
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Running project takes 1 minute

Post by jvierra »

stevens wrote:
Thu Apr 09, 2020 1:13 am
Thanks, but disabling that didn't help. Still takes long time (little bit less now).
I do think it was a setting I changed though. One day it was working fine (started in seconds), next day it takes a minute.
Then it is not really a PowerShell issue is it?

User avatar
stevens
Posts: 416
Joined: Wed Jun 15, 2016 2:26 am

Re: Running project takes 1 minute

Post by stevens »

No, it is the form which loads really slow.

jvierra
Posts: 14437
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Running project takes 1 minute

Post by jvierra »

The form is PowerShell. It is PowerShell that is loading the form.

Anything in the "Load" event will prevent the form from displaying until the load event terminates. What are you doing in the load event? Run the PS1 in the console and see if it loads any faster. If the load event is taking too much time then the form will not display. The form only displays after the load event ends. Any code running outside of an event will also stop the form from displaying until it is done executing. In a project, any code running in "startup.pss" or "globals.ps1" will also prevent the form from displaying.


It i almost always the case that a slow form is caused by incorrect program design. This is true of all languages that display a form and is true on non-Windows systems form mainframes to Unix to Macs.

Locked