Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

A question about Win32

I'm a newbie to win32 programming. As a typical structure of message loop in Win32 program as following:

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

while the program is idling in the background, the loop should be running continuously. But why isn't this program occupying all the CPU time?

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : I'm a newbie to win32 programming. As a typical structure of message loop in Win32 program as following:
    : [code]
    : StartLoop:
    : invoke GetMessage,ADDR msg,NULL,0,0
    : cmp eax, 0
    : je ExitLoop
    : invoke TranslateMessage, ADDR msg
    : invoke DispatchMessage, ADDR msg
    : jmp StartLoop
    : ExitLoop:
    : [/code]
    : while the program is idling in the background, the loop should be running continuously. But why isn't this program occupying all the CPU time?
    [blue]The code is correct, but it will change if you are going to use accelerators or modeless dialogs in your code.

    Also, there is no idle time, because when there is no messages - Windows waits INSIDE GetMessage() until message comes. Windows does it without looping and taking up CPU resource, but with interrupts.[/blue]
    :

  • stanley_huangstanley_huang Posts: 2Member
    thanx dude! i got the main idea!
Sign In or Register to comment.