Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ShellExecute very slow

493 views
Skip to first unread message

Francois Piette [ICS & Midware]

unread,
Jan 25, 2007, 9:46:48 AM1/25/07
to
I have a strange problem in one of my applications: I use ShellExecute to
open a rtf document (I use 'open' and rtf filename which result in launching
Word). This works fine except at one place in my program where it experience
a very long delay (30 to 60 sec) before launching Word. No error, just a
long delay. I can't find what is causing such a delay ! Any hint
appreciated.

--
francoi...@overbyte.be
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


Peter Below (TeamB)

unread,
Jan 25, 2007, 2:36:11 PM1/25/07
to
Francois Piette [ICS & Midware] wrote:

> I have a strange problem in one of my applications: I use
> ShellExecute to open a rtf document (I use 'open' and rtf filename
> which result in launching Word). This works fine except at one place
> in my program where it experience a very long delay (30 to 60 sec)
> before launching Word. No error, just a long delay. I can't find what
> is causing such a delay ! Any hint appreciated.

Sounds like a timeout, e.g. caused by a window whos owner thread is
blocked when the shell tries to establish a DDE connection to the
running Word instance.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Francois PIETTE [ICS - MidWare]

unread,
Jan 25, 2007, 2:59:20 PM1/25/07
to
>> I have a strange problem in one of my applications: I use
>> ShellExecute to open a rtf document (I use 'open' and rtf filename
>> which result in launching Word). This works fine except at one place
>> in my program where it experience a very long delay (30 to 60 sec)
>> before launching Word. No error, just a long delay. I can't find what
>> is causing such a delay ! Any hint appreciated.

> Sounds like a timeout, e.g. caused by a window whos owner thread is
> blocked when the shell tries to establish a DDE connection to the
> running Word instance.

I've found the source of the problem but I don't understand why it is
causing long delays in ShellExecute. In /another/ application there is a
worker thread with a message queue (PeekMessage has been called). When this
worker thread is suspended, then ShellExecute in to /other/ application
experience a long delay.

It looks like ShellExecute send a message to the suspended thread which of
course doesn't respond to the message and cause ShellExecute to wait 30" or
so and then continue quitely. The result being Word launch delay. I have no
idea why ShellExecute would send a message to a thread in /another/
application before launching word !

Any idea appreciated.

--
francoi...@overbyte.be
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


Peter Below (TeamB)

unread,
Jan 26, 2007, 1:20:55 PM1/26/07
to
Francois PIETTE [ICS - MidWare] wrote:

> > > I have a strange problem in one of my applications: I use
> > > ShellExecute to open a rtf document (I use 'open' and rtf filename
> > > which result in launching Word). This works fine except at one
> > > place in my program where it experience a very long delay (30 to
> > > 60 sec) before launching Word. No error, just a long delay. I
> > > can't find what is causing such a delay ! Any hint appreciated.
>
> > Sounds like a timeout, e.g. caused by a window whos owner thread is
> > blocked when the shell tries to establish a DDE connection to the
> > running Word instance.
>
> I've found the source of the problem but I don't understand why it is

> causing long delays in ShellExecute. In another application there is


> a worker thread with a message queue (PeekMessage has been called).

> When this worker thread is suspended, then ShellExecute in to other


> application experience a long delay.
>
> It looks like ShellExecute send a message to the suspended thread
> which of course doesn't respond to the message and cause ShellExecute
> to wait 30" or so and then continue quitely. The result being Word
> launch delay. I have no idea why ShellExecute would send a message to

> a thread in another application before launching word !

That is exactly what I meant in my reply. Word has registered itself as
a DDE server when installed. The ShellExecute function, looking for
the server application to call for a file that Word has registered
itself for, will not simply start a new instance of Word, it tries to
establish a DDE connection to an already running instance of Word (even
if there is none running). This involves broadcasting a message to all
top-level windows on the active desktop. And if one of them is owned by
a thread that happens to be blocked then the broadcast will stall for
this window until it times out.

A thread owning a window for message processing purposes must never be
suspended, and if it needs to wait on something other than a message
(via GetMessage or WaitMessage) it has to use MsgWaitForMultipleObjects
to wait, so it can wake up when a message comes in and process it.

0 new messages