Click here to Skip to main content
15,912,756 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ASSERT()! Why?And how to resolve it? Pin
Roger Stoltz14-Jun-07 1:04
Roger Stoltz14-Jun-07 1:04 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic14-Jun-07 1:17
kcynic14-Jun-07 1:17 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
Roger Stoltz14-Jun-07 1:32
Roger Stoltz14-Jun-07 1:32 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic14-Jun-07 2:08
kcynic14-Jun-07 2:08 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
Roger Stoltz14-Jun-07 3:45
Roger Stoltz14-Jun-07 3:45 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic14-Jun-07 19:35
kcynic14-Jun-07 19:35 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic14-Jun-07 19:54
kcynic14-Jun-07 19:54 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
Roger Stoltz15-Jun-07 0:15
Roger Stoltz15-Jun-07 0:15 
kcynic wrote:
m_pClientThread->m_socket.SetTarget(dlg);


This implies that you've modified the original source code that Newcomer wrote since the m_socket member was originally protected and the above would generate a compiler error if it still is. So you "fixed" the compiler error by making the member publicly declared instead.
The bad news is that you've made this change to the original code in order to use it in a way it wasn't intended.

The design that Newcomer made is built on the idea that each socket informs the main window/thread about things of interest, such as when the socket thread has started and when the user has to be notified for some reason. You should not brake this design.
When the socket thread needs to notify the main window, it posts a user defined message to it. This is what the target member is for. Changing the target to a "temporary" window while the thread is running will create various race conditions that eventually will lead to the ASSERT you got. This may happen since at some point the socket thread will try to post a message to a window that doesn't exist any longer or for some other obscure reason. You may find the reason if you follow Naveen.R's advice about the call stack. You will probably find a call to CWnd::PostMessage() or CWnd::SendMessage() in the call stack in a socket thread.

What you should do is keep the design and let the main window be the "information collector". If you want to create other windows, they could register themselves as observers to the main window so the main window can inform them about events of interest.
But whatever you do you cannot change the "target" window after the socket thread has been allowed to start.

I guess it boils down to a question about design.
What are your dialog windows supposed to do?


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic15-Jun-07 0:44
kcynic15-Jun-07 0:44 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
Roger Stoltz15-Jun-07 1:35
Roger Stoltz15-Jun-07 1:35 
GeneralRe: ASSERT()! Why?And how to resolve it? Pin
kcynic14-Jun-07 20:32
kcynic14-Jun-07 20:32 
Questionpicture control Pin
tyagineha14-Jun-07 0:17
tyagineha14-Jun-07 0:17 
AnswerRe: picture control Pin
Mark Salsbery14-Jun-07 7:50
Mark Salsbery14-Jun-07 7:50 
GeneralRe: picture control Pin
Hamid_RT14-Jun-07 20:09
Hamid_RT14-Jun-07 20:09 
QuestionRe: picture control Pin
tyagineha14-Jun-07 20:17
tyagineha14-Jun-07 20:17 
AnswerRe: picture control Pin
Mark Salsbery15-Jun-07 5:37
Mark Salsbery15-Jun-07 5:37 
QuestionGetting TCP/UDP Tables with ProcessIDs before XP Pin
Akin Ocal13-Jun-07 23:17
Akin Ocal13-Jun-07 23:17 
QuestionDebugging in VC++ Pin
Raj Prathap13-Jun-07 23:08
Raj Prathap13-Jun-07 23:08 
AnswerRe: Debugging in VC++ Pin
Programm3r13-Jun-07 23:15
Programm3r13-Jun-07 23:15 
GeneralRe: Debugging in VC++ Pin
Raj Prathap13-Jun-07 23:24
Raj Prathap13-Jun-07 23:24 
GeneralRe: Debugging in VC++ Pin
Programm3r13-Jun-07 23:41
Programm3r13-Jun-07 23:41 
AnswerRe: Debugging in VC++ Pin
Naveen13-Jun-07 23:29
Naveen13-Jun-07 23:29 
GeneralRe: Debugging in VC++ Pin
Raj Prathap13-Jun-07 23:59
Raj Prathap13-Jun-07 23:59 
GeneralRe: Debugging in VC++ Pin
Nibu babu thomas14-Jun-07 0:38
Nibu babu thomas14-Jun-07 0:38 
QuestionVARIANT Bitmap Pin
shiraztk13-Jun-07 22:11
shiraztk13-Jun-07 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.