Page 1 of 1

ElapsedMilliseconds()

Posted: Wed Aug 26, 2009 3:02 pm
by ebs
Can anyone tell me what code and/or Windows API calls are used for the "ElapsedMilliseconds()" function?

One of my programs has a simple splash screen (just 3 TextGadgets), which is displayed like this:

Code: Select all

; display splash screen
OpenWindow_Window_Splash()
st.l = ElapsedMilliseconds()
Repeat
  While WindowEvent():Wend
Until ElapsedMilliseconds() - st = 1500
CloseWindow(#Window_Splash)
This works fine on almost every machine, except one. On this PC,
the splash screen never closes, and the CPU usage goes up close to 100%.
The problem PC is running Windows XP SP2, but I have also seen the same result on Vista.

Can anyone help me understand why this hangs, and maybe suggest a better way to do it?

Thanks for your help,
Eric

Posted: Wed Aug 26, 2009 3:28 pm
by nco2k

Code: Select all

Until ElapsedMilliseconds() - st >= 1500
c ya,
nco2k

Posted: Wed Aug 26, 2009 3:42 pm
by ebs
Of course!!! :oops:
I'm surprised that it did work on most of the machines!

Thanks,
Eric

Posted: Wed Aug 26, 2009 4:56 pm
by Trond

Code: Select all

Repeat 
  While WindowEvent():Wend 
Until ElapsedMilliseconds() - st <= 1500
This will always use 100% cpu. There is no delay in there. Better use WaitWindowEvent(15).

In any case, the code seems meaningless. The splash screen is displayed when the program loads to show the user that the program loads. With this code, the program doesn't do anything when the splash screen is there, which is just a waste of time.

Posted: Wed Aug 26, 2009 5:15 pm
by ebs
Trond wrote:This will always use 100% cpu. There is no delay in there. Better use WaitWindowEvent(15).
That's a good idea - thanks.
Trond wrote:In any case, the code seems meaningless. The splash screen is displayed when the program loads to show the user that the program loads. With this code, the program doesn't do anything when the splash screen is there, which is just a waste of time.
The purpose of the splash screen is just to display the customer that the program is licensed to.
The main window opens immediately after the splash screen closes, and the program is ready to go.
It is a small waste of time (1.5 seconds), but a necessary one.

Thanks for your suggestion.

Posted: Wed Aug 26, 2009 7:29 pm
by talisman
May I add my personal opinion on this? Whether the application is targeted for personal or business use, I feel that splash screens of any nature are a waste of time and usefulness. Sure, one and a half seconds might sound small, but being an aggressive multitasking maniac myself I want everything to open up snappy without any delays and let my computer decide when it wants to slow things down or not. If you really must show whom the application is licensed to, maybe you could use the window title for this. Something like "My Application (Licensed to: Client, My)" will definitely work. Besides, you can always have the splash screen there, just make it show up whenever the user chooses so from the menu (Help -> About anyone?).

Anyway, just my personal opinion so decide on your own how you want to do it. Your application after all :)

Posted: Wed Aug 26, 2009 7:56 pm
by Kaeru Gaman
another possibility is, to put the splashscreen topmost and open the window in the back without any delay, and disable the splashscreen on the first click on the surface.
this makes the sc visible as long as possible without any delay for the functionality.
the editor for civ3 does it this way.

Posted: Wed Aug 26, 2009 8:36 pm
by Trond
Yes, splash screens that are not there to show that the program is actually doing something are ridiculous and ignorant.

In any case, it seems irrational that one would care who the application was registered to. And if one actually cares, it seems irrational that this information would be available for only 1.5 second (read fast!) on program startup (to find out who it's registered to you have to close the program and restart it!).

Sorry about ranting but honestly, it is well deserved! :twisted:

Posted: Wed Aug 26, 2009 9:00 pm
by Kale
IMHO there is nothing wrong with splash screens as long as they are asynchronous and show useful program information. Once the main app has loaded, however, they should disappear.

Posted: Sun Sep 06, 2009 10:56 pm
by Rescator
You might want to consider the new (PB4.40) message timer instead.