Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CDaoDatabase for Opening MS-Access Pin
Jochen Arndt23-Apr-13 0:03
professionalJochen Arndt23-Apr-13 0:03 
QuestionMulti Threaded ::ShowWindow(...) Pin
Bram van Kampen22-Apr-13 13:58
Bram van Kampen22-Apr-13 13:58 
AnswerRe: Multi Threaded ::ShowWindow(...) Pin
«_Superman_»22-Apr-13 17:07
professional«_Superman_»22-Apr-13 17:07 
QuestionRe: Multi Threaded ::ShowWindow(...) Pin
David Crow23-Apr-13 4:53
David Crow23-Apr-13 4:53 
AnswerRe: Multi Threaded ::ShowWindow(...) Pin
«_Superman_»23-Apr-13 17:35
professional«_Superman_»23-Apr-13 17:35 
GeneralRe: Multi Threaded ::ShowWindow(...) Pin
David Crow24-Apr-13 2:07
David Crow24-Apr-13 2:07 
Questionget all domains form adsi forest Pin
venkatesh5286722-Apr-13 0:29
venkatesh5286722-Apr-13 0:29 
QuestionThreads and messages - is this legal? Pin
charlieg21-Apr-13 15:31
charlieg21-Apr-13 15:31 
I think my past sins and assumptions are coming home to haunt me. I have a fairly large/complex application that began its past life in another product. Consider it a dialog application with a lot of dialogs. The dialogs can become 3 or more deep. On rare and random occasions, the application will crash with a stack overflow exception - only when leaving a dialog. The exception happens somewhere after EndDialog processes.

Yes, I have checked stack usage - I'm well under the specified amount. The problem is very rare. My debug efforts have led me to the path of suspecting some sort of race condition in message processing or some other undetected data corruption.

The application itself uses your standard windows messages. However, I have a number of worker threads that post messages into the application message queues. My approach is what I need a basic sanity check on

In the InitInstance, I create a worker thread using ::CreateThread() - system timer, whose sole responsibility is to notify active dialogs that a time event has occurred. This thread:

- acquires a pointer to CWnd via AfxGetApp().
- posts the message to the window using PosteMessage()
- there is no stack allocated data passed of any kind whatsoever in these messages.

Based on what I have read about this approach, it's legal and the only appropriate way for a worker thread to send data to the GUI thread. Opinions?

My next question has to do with what I consider to be a possible race condition. Given that my worker thread is firing off messages irrespective of what is going on elsewhere in the application, is it possible for the worker thread to send a message to a window AND have the user press the "Exit" button before the message arrives? If so, I would expect the dialog to be in some sort of tear down state such that some of it's processing is indeterminate. Is my concern reasonable?
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.

"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759


AnswerRe: Threads and messages - is this legal? Pin
pasztorpisti21-Apr-13 19:28
pasztorpisti21-Apr-13 19:28 
GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 4:34
charlieg22-Apr-13 4:34 
GeneralRe: Threads and messages - is this legal? Pin
pasztorpisti22-Apr-13 6:46
pasztorpisti22-Apr-13 6:46 
GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 11:20
charlieg22-Apr-13 11:20 
GeneralRe: Threads and messages - is this legal? Pin
PJ Arends22-Apr-13 12:00
professionalPJ Arends22-Apr-13 12:00 
GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 11:20
charlieg22-Apr-13 11:20 
GeneralRe: Threads and messages - is this legal? Pin
pasztorpisti22-Apr-13 22:46
pasztorpisti22-Apr-13 22:46 
AnswerRe: Threads and messages - is this legal? Pin
Stephen Hewitt22-Apr-13 20:48
Stephen Hewitt22-Apr-13 20:48 
GeneralRe: Threads and messages - is this legal? Pin
charlieg23-Apr-13 14:17
charlieg23-Apr-13 14:17 
QuestionName Space Vs Include Pin
Bram van Kampen21-Apr-13 14:51
Bram van Kampen21-Apr-13 14:51 
AnswerRe: Name Space Vs Include Pin
pasztorpisti21-Apr-13 19:40
pasztorpisti21-Apr-13 19:40 
GeneralRe: Name Space Vs Include Pin
Bram van Kampen28-Apr-13 0:34
Bram van Kampen28-Apr-13 0:34 
QuestionHiding the folder from the explorer Pin
sarfaraznawaz18-Apr-13 23:59
sarfaraznawaz18-Apr-13 23:59 
AnswerRe: Hiding the folder from the explorer Pin
André Kraak20-Apr-13 8:17
André Kraak20-Apr-13 8:17 
GeneralRe: Hiding the folder from the explorer Pin
Bram van Kampen21-Apr-13 15:19
Bram van Kampen21-Apr-13 15:19 
AnswerRe: Hiding the folder from the explorer Pin
Stefan_Lang22-Apr-13 0:26
Stefan_Lang22-Apr-13 0:26 
Questionhow to start a thread to get webinfo(xml) with chttpfile Pin
haha_c18-Apr-13 22:54
haha_c18-Apr-13 22:54 

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.