[python-win32] DispatchWithEvents design question

Tim Roberts timr at probo.com
Thu Jun 7 18:32:29 CEST 2007


Richard Bell wrote:
> I rewrote the test, see below.  When run it behaves as you suggest (see the
> test output below).  In particular the OnVisible event occurs synchronously
> before return from 'ie.Visible = 1' as you suggested.  I checked StatusBar
> and it appears to be synchronous as well.  I assume then that any events
> associated with setting IE's properties would also be synchronous, wouldn't
> they?  
>   

Yes, I would expect that.

> But note that when I set StatusBar false the OnStatusBar event occurs.  Then
> when I set StatusBar true both OnCommandStateChange and OnStatusBar events
> occur.  I expected the OnStatusBar event but NOT the OnCommandStateChange
> event as later in the test (after 21.407) OnCommandStateChange behaves
> asynchronously.

It's quite possible for a single callback to happen both synchronously
and asynchronously, depending on context.  In this case, IE probably
considers the StatusBar to be one of its "commands", so the
OnCommandStateChange makes some sense.

> Is there some bit of behavior such that when a synchronous
> event occurs other queued events are also processed?  About a year ago, Mark
> Hammond helped me in this area and memory serves that when any events are
> processed they are all processed.  Is this true?  Is this behavior a
> function of COM or of the Python COM interface?  
>   

I don't know this, and frankly I'm not sure there are any hard and fast
rules to rely on.

> More generally, how do I know what COM interactions will generate
> synchronous events and which will cause asynchronous events?

I'm afraid experience is the only teacher here.

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



More information about the Python-win32 mailing list