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.
This topic is 3 years and 8 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
ClipperXTP
Posts: 55
Last visit: Thu Jun 24, 2021 3:05 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 55
Last visit: Thu Jun 24, 2021 3:05 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.
This topic is 3 years and 8 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