Re: Is this OK?
- From: "Ben Voigt" <rbv@xxxxxxxxxxxxx>
- Date: Thu, 21 Dec 2006 09:01:24 -0600
"William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx> wrote in message
news:%23d3bw3lHHHA.816@xxxxxxxxxxxxxxxxxxxxxxx
"Vincent Fatica" <abuse@xxxxxxxxxxxxx> wrote in message
news:457f5f41$1@xxxxxxxxxxxxxxxxxxxx
The CreateNamedPipe() is outside the wnd-enum proc ... called before
EnumWindows() so the enum-proc can re-use the pipe for each window it
wants to
get info from. It all works fine when the window proc is in another
process.
When the window proc is in the same (single-threaded) process, the
querying side
(enum-proc) never gets past ConnectNamedPipe(), while the responding side
gets
to WriteFile() (which blocks). Reading the docs, I figured the
responding
side's CreateFile() would satisfy the ConnectNamedPipe() (regardless of
which
happens first).
Sorry, I'm running a bit slow today - this is the second time I failed to
grok what a poster was doing.
And jeez, I do hope I don't go for #3 but now I _think_ I understand.
You read the pipe on your application's main thread, is that it? If so,
that's the same thread on which your window procedure runs. And therein
lies the rub - neither the read nor the write can complete because they
both run on the same thread and each requires the other's completion.
Hello deadlock.
If that's it, you _might_ be able to cook up something with asynchronous
operations on the pipe but in short the problem may be that you are
breaking Windows first commandment - Thou shalt pump messages. It's almost
never a good idea to do anything in the UI thread which has a chance to be
a long running operation.
Just use ReadFileEx and WriteFileEx and continuations (then make your main
thread loop use MsgWaitForMultipleObjects with the alertable flag). No
blocking.
Again, off the top of my head, I think if you put the pipe creation and
connection logic in a secondary thread the intra and inter process cases
should behave the same.
Regards,
Will
.
- References:
- Is this OK?
- From: Vincent Fatica
- Re: Is this OK?
- From: Tim Roberts
- Re: Is this OK?
- From: Vincent Fatica
- Re: Is this OK?
- From: William DePalo [MVP VC++]
- Re: Is this OK?
- From: Vincent Fatica
- Re: Is this OK?
- From: William DePalo [MVP VC++]
- Re: Is this OK?
- From: Vincent Fatica
- Re: Is this OK?
- From: William DePalo [MVP VC++]
- Is this OK?
- Prev by Date: Re: recv WSAENOBUFS error
- Next by Date: Re: Thunking PrintDlg
- Previous by thread: Re: Is this OK?
- Next by thread: Hardware x86 breakpoints in Windows XP SP2 and Windows Server 2003.
- Index(es):
Relevant Pages
|