[Dev] Sending Messages to the UI Thread

Donn Denman donn at osafoundation.org
Tue Sep 21 16:05:37 PDT 2004


There's a new way to send a message to the UI thread from any other 
thread.   The mechanism lets you call any method on any Item, and it 
handles converting arguments from Item to UUID and back again 
automatically.  We're currently using the new mechanism in a lot of our 
Mail sending/receiving to tell the MainView to put progress messages in 
the status bar.  See NotifyUIAsync() at the top of imap.py for example 
usage.

Details:
----------
The code is all in chandler/application/Application.py.  There's a 
helper class to convert Items to/from UUID called TransportWrapper.  
But the bulk of the code is in wxApplication.  The method that does the 
sending work is named CallItemMethodAsync(), and it takes variable 
parameters.  It wraps all the parameters into UUIDs, and then posts a 
message to the UI thread.  When the UI thread gets the message, it 
calls _DispatchItemMethod() to do the method dispatch.  
_DispatchItemMethod unwraps the parameters (which converts them back 
into Items), locate the method on the item to call, and calls it with 
the converted parameters.



More information about the Dev mailing list