A question about Win32 - Programmers Heaven

Howdy, Stranger!

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

Categories

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.