Jump to content

GUI performance question


nitro322
 Share

Recommended Posts

I have two separate applications that both create GUI windows. One of them, which I'll call the Good App, properly idles while the GUI is displayed (ie, doesn't use any extra CPU cycles), while the other one will consume every last bit of CPU resources, even while idle (aka, the Bad App). I can't figure out why they behave differently in this respect.

I've been looking through the code, and each of them utilize a 'while 1' loop structure to display the GUI until a certain action is performed. The main difference, as far as I can tell is that the Good App uses GuiGetMsg() within the loop to determine the action, whereas the Bad App uses GuiCtrlSetOnEvent() declared outside the loop to determine the action. Ex:

GUISetState(@SW_SHOW)
while 1
   $action = GUIGetMsg()
   select
      case $action = $ok
         ...
         exitloop
      case $action = $cancel
         exit
   endselect
wend

GUISetOnEvent($GUI_EVENT_DROPPED, "GUI_Drop")
GUISetOnEvent($ok, "GUI_Ok")
GUISetOnEvent($cancel, "GUI_Cancel")
GUICtrlSetState(@SW_SHOW)
$finishgui = 0
while 1
   if $finishgui then exitloop
exit

At first glance it may seem that the GUISetOnEvent() functions is the problem, since the app using just GUIGetMsg() idles properly. However, I tried commenting out each of the GUISetOnEvent() functions (so that the app is literally a dumb GUI that needs to be killed from task manager), and it still consumed 100% CPU resources. Another line of thought might be that a 'while 1' loop as I have structured will be infinitely busy, and therefore will consume all available resources, but this cannot be true as the code in the first example works just fine.

At this point I'm out of ideas. Can anyone offer any suggestions? I'll be happy to post real code if it'd help for troubleshooting instead of the examples above.

Thanks a bunch.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...