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

C / C++ / MFC

 
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 
AnswerRe: Threads and messages - is this legal? Pin
pasztorpisti21-Apr-13 19:28
pasztorpisti21-Apr-13 19:28 
Imagine the gui thread as a special thread that has a job queue (because it has one). The main loop of the application (in the gui thread) is spinning and gets/processes messages that it retrievees with PeekMessage() or GetMessage() from its per-thread message queue. Putting a message to this message queue with PostMessage() for later processing is OK. Putting a message to the queue with SendMessage() is also OK. The difference between the two is that SendMessage() waits till the end of message processing so you can safely pass even pointers that point to your stack, and you can process the return value immediately. To tell the exact reason of your problem you need to give more info:
Which CWnd? Main wnd? Dialog wnd? What is the scope/lifetime of the CWnd? What is the scope/lifetime of the thread? Which Exit button? The one that terminates the whole application or just one of your dialog boxes?

There are several other things you should consider: MFC itself is not thread safe. If you use for example CWnd retriever methods than you are accessing a window map that is sometimes modified by the gui thread. Maybe your only problem is that you should get a HWND on the gui thread and pass that as a message target to the worker thread when you create it. Another possible problem is that on the main thread you should ask the worker thread to terminate and wait for it to terminate at some point. For example when the main window is destructed.
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 
AnswerRe: how to start a thread to get webinfo(xml) with chttpfile Pin
Marco Bertschi18-Apr-13 23:25
protectorMarco Bertschi18-Apr-13 23:25 

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.