Show-SplashScreen and GUI Load Times

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.
Locked
ClipperXTP
Posts: 31
Joined: Tue Apr 28, 2020 4:07 am

Show-SplashScreen and GUI Load Times

Post by ClipperXTP »

It takes about 6/7 seconds for my Windows Form GUI to load after double click.

I've had some of my users comment that when they double click on the .exe they think nothing has happened and they double click it again etc.

I tried Show-SplashScreen in the form load event and it looks great but the splash screen still takes about 5 seconds to appear... Not ideal.

I've put a System.Windows.Forms.MessageBox on line 1 of the code and that gives immediate proof of life when the .exe is double clicked. Message gets user to 'click OK to continue, form will load shortly', and sure enough the form goes on to load. It would be nicer to have a splash screen though with a nice picture.

I tried t $SS = show-splashscreen ... -passthru on line 1 and it looked great - user double clicks and straight away they get splash screen, but the form fails to load.
I tried $SS.close() as part of the form load event and it closes the splash screen the main form doesn't load.

Any way this can be done?

thanks

jvierra
Posts: 14667
Joined: Tue May 22, 2007 9:57 am
Answers: 5
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Show-SplashScreen and GUI Load Times

Post by jvierra »

Load time is dependent on all of the code that execute before the Load event fires. What is your code doing that is taking so long.

ClipperXTP
Posts: 31
Joined: Tue Apr 28, 2020 4:07 am

Re: Show-SplashScreen and GUI Load Times

Post by ClipperXTP »

Hi JV
thanks for your reply. It's opening one database connection. There's about 4000 lines of code that do various queries to machines and web services when buttons are clicked. On load there is also a set control theme to 'dark' which takes a couple of seconds even on the most basic form.
As I said, I have gotten around it with the message box but it would be nice if I could get a splash screen to load straight off the bat like the message box does.

jvierra
Posts: 14667
Joined: Tue May 22, 2007 9:57 am
Answers: 5
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Show-SplashScreen and GUI Load Times

Post by jvierra »

To make the form or any sub forms visible all of your work code needs to be in the "Shown" event. This fires after teh form is displayed.

Locked