repeat something in a thread, but stop when the program stops

Jeff Shannon jeff at ccvcorp.com
Wed Sep 29 20:07:39 CEST 2004


Harald Massa wrote:

>My impression from reading dispatcher-code was more in the area of:
>
>a=get_message_from_windows()
>
>if a==waaaah_they_clicked_on_me:
>   give_it_to_them_REAL_hard()
>elif a==they_hover_over_me:
>   do_some_hover_action()
>
>with "get_message_from_windows()" silently and cycle-free blocking until 
>windows decides to distribute a message. Something like a blocking 
>socket, which makes a program wait.
>  
>

Essentially true, but Windows sends a lot more messages than most people 
realize, even to "dormant" apps sitting in the system tray.  Even if you 
code your own windowproc and handle a bunch of messages yourself, the 
vast majority of Windows messages get passed on to DefWindowProc() 
(provided by Windows). 

Of course, the point is that in practice, it hardly matters.  On any 
reasonably recent PC, handling a few hundred messages every second is 
trivial.  (As long as the message handlers don't access "slow" 
resources, at least...)

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list