[python-win32] DispatchWithEvents design question

Tim Roberts timr at probo.com
Fri Jun 8 02:47:22 CEST 2007


Richard Bell wrote:
> Is it then the case that my OnEvent routines should only execute under one
> of the following conditions?
>
> 1 - I interact with the COM target as in ie.Visible = 1 or ie.Navigate2
> 2 - I execute a pythoncom.PumpWaitingMessages
>   

I believe this to be true.  You are apartment-threaded, which means you
are saying you will only accept events on the thread that created the
object.  The only ways to accept events on your thread are the two ways
you outline above.

Now, could a COM object violate that contract and send you events on
another thread?  Yes, but it would be a COM bug, and Microsoft is pretty
careful about having their own objects follow the rules.

> In particular, is it true if I'm automating IE and the user moves or resizes
> the browser window or some other action that caused events then those events
> will queue and my OnEvent routines will NOT run until such time as I again
> interact with COM or pump messages?  Thus when I'm not interacting
> explicitly with COM (apartment-threaded) unanticipated On-event routine
> execution is NOT possible.
>   

If you do get them, it is a bug in IE or in COM.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list