Re: CAsyncSocket behaving multithreaded
From: Jo (JoJoTwilligo_at_hotmail.com)
Date: 11/10/04
- Next message: Jeff F: "Re: Updating Controls from a Thread Causes Access Violation"
- Previous message: Jim Howard: "Re: Updating Controls from a Thread Causes Access Violation"
- In reply to: Scott McPhillips [MVP]: "Re: CAsyncSocket behaving multithreaded"
- Messages sorted by: [ date ] [ thread ]
Date: 10 Nov 2004 11:42:25 -0800
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message news:<esNBXZyxEHA.4028@TK2MSFTNGP15.phx.gbl>...
> Jo wrote:
> > I'm aware that CAsyncSocket is not supposed to be multithreaded, but
> > just uses the message pump. So why are some of my On*() overridables
> > being called when others haven't finished yet? It's been suggested
> > that an AfxMessageBox() might cause another overridable to be called.
> > That's not the case, but in one case, I'm having an overridable being
> > called after I step into a pointer assignment operation. Check it out:
> >
> > pNewNode->data = newElement; // line 843 in afxtempl.h
> >
> > Now, if I'm at that assignment, and I push F11, how is it that I next
> > find I'm at one of my breakpoints in OnReceive()? Especially when I've
> > already got an OnReceive() in progress? The last time I had this
> > problem I made a workaround, but now that this multithreaded behavior
> > is happening all the time, I need a real solution.
> >
>
> Examine the debugger stack display when the unexpected OnReceive is hit.
> One possibility here is that the pointer assignment operation causes
> an access violation or assert error, and that the debug environment
> attempts to display a message box about this error, and that the message
> box message pump permits the second OnReceive to be called. If the
> stack is not corrupt you would see evidence in the stack of various
> library routines attempting to display an error box.
It looks like this is probably it. I wasn't able to test the
earlier problem with the pointer assignment, but your explanation
doesn't fit what I remember about it. However, in my current code, I
removed the extra calls to Receive(), which didn't clear up the
problem. But I found that in one case an assertion was indeed being
triggered, and before I could get the message, I was sent on a wild
goose chase away from the problem and into the OnReceive(). It's
probably worth remembering this the next time I have a problem like
this.
Thanks very much for your help. I seem to need a lot of it debugging
the unpredictable CAsyncSocket.
- Next message: Jeff F: "Re: Updating Controls from a Thread Causes Access Violation"
- Previous message: Jim Howard: "Re: Updating Controls from a Thread Causes Access Violation"
- In reply to: Scott McPhillips [MVP]: "Re: CAsyncSocket behaving multithreaded"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|