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
Joined: Wed Jun 15, 2016 2:26 am

Re: Running project takes 1 minute

Post by stevens »

Thanks for your feedback. It is indeed the project itself. Another project does not have any problem.
Though the problem appeared one day out of the blue and I have no clue why, reverted some changes but didn't help. I also have no indication where to look for :-( So I'm building it each time I want to test as workaround (that loads really fast), but would be nice to know what is going on.

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

Re: Running project takes 1 minute

Post by jvierra »

Also note that anyth8ing that runs in startup.pss or glbals.ps1 will also delay the display of the first form.

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

Re: Running project takes 1 minute

Post by stevens »

If anybody would have told me that I can run the project "in console" I would have found what is going on. There are so many features, just didn't see that one.
Now I can easily see when a form doesn't startup what blocks it (was another post of me). Actually that just happened, then noticed that option and immediately could debug.
Same with slow starting, now I can see it tries to do stuff it should not and I can correct so speed up startup without any problem.

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

Re: Running project takes 1 minute

Post by jvierra »

That was one of the first things I suggested.

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

Re: Running project takes 1 minute

Post by stevens »

Thanks. When I look back in the posts I don't see it.
I'm probably overlooking it then.
---
Now I know why the GUI loads slow. It is new code that was suggested on this forum.
I'm using
$form.text = "Running $RuntimeVersion" which is showing the version fine in the GUI.
I get the $RuntimeVersion from the globals.ps1 where I have this code:
$RuntimeFileInfo = Get-Item $hostinvocation.MyCommand.path
$RuntimeVersion = $($RuntimeFileInfo.VersionInfo.ProductVersion

-But when I launch the GUI via 'run in console' I get this all the time
Get-Item : Cannot bind argument to parameter 'Path' because it is null
At ... Globals.ps1:330 char:29
+ $RuntimeFileInfo = Get-Item $hostinvocation.MyCommand.path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Item], ParameterBindingValidat

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

Re: Running project takes 1 minute

Post by jvierra »

As I posted much earlier. Generate the PS1 file for the project and run that in a console. A PS console.

Some variables only exist when run under the Sapien host.

The script path is always available from the following: Get-ScriptDirectory. The function must only be called after it is defined.

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

Re: Running project takes 1 minute

Post by stevens »

See viewtopic.php?f=21&t=14566
The code Nillth provided is exactly what I am using
$RuntimeFileInfo = Get-Item $hostinvocation.MyCommand.path
$RuntimeVersion = $($RuntimeFileInfo.VersionInfo.ProductVersion)

As mentioned, it works fine, the $RunTime version shows correctly, so I wouldn't know what to change and where ... but the load of the gui shows
Get-Item : Cannot bind argument to parameter 'Path'

So I'm puzzled here.

Locked