Click here to Skip to main content
15,888,000 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to do logiz gates Pin
Syed umair shah23-Jun-12 0:45
Syed umair shah23-Jun-12 0:45 
AnswerRe: how to do logiz gates Pin
Software_Developer23-Jun-12 11:07
Software_Developer23-Jun-12 11:07 
QuestionWhat FTP pack can obtain the detail events? Pin
includeh1022-Jun-12 22:36
includeh1022-Jun-12 22:36 
AnswerRe: What FTP pack can obtain the detail events? Pin
Jochen Arndt22-Jun-12 23:03
professionalJochen Arndt22-Jun-12 23:03 
QuestionOnly unist.isu gets installed by visual C++ install shield Pin
adityarao3122-Jun-12 20:30
adityarao3122-Jun-12 20:30 
QuestionMFC UI Thread vs. Background Thread Pin
Richard Andrew x6422-Jun-12 10:19
professionalRichard Andrew x6422-Jun-12 10:19 
AnswerRe: MFC UI Thread vs. Background Thread Pin
«_Superman_»22-Jun-12 17:19
professional«_Superman_»22-Jun-12 17:19 
SuggestionRe: MFC UI Thread vs. Background Thread Pin
Roger Stoltz23-Jun-12 0:26
Roger Stoltz23-Jun-12 0:26 
«_Superman_» wrote:
In MFC, you should not directly access UI elements from background threads.


True.


«_Superman_» wrote:
Instead, you must send messages to the UI thread to get and set elements for the UI.

Use can use SendMessage or PostMessage.


Not entirely true.
The reason for not accessing UI elements from another thread than the main thread is that you can quite easily create a deadlock situation. MFC classes for UI elements uses ::SendMessage() which will block until the message has been handled. If the main thread is not processing messages, possibly waiting for the thread that manipulates the UI element, the application will deadlock.
This of course means that you cannot use ::SendMessage(), even if you call it directly, as it would create the same potential deadlock situation.

::PostMessage() must be used since it doesn't wait for the message to be handled. It is possible to use ::SendMessageTimeout() to avoid a deadlock situation, but if the call fails the receiving thread never gets the message.

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


GeneralRe: MFC UI Thread vs. Background Thread Pin
Richard Andrew x6423-Jun-12 8:31
professionalRichard Andrew x6423-Jun-12 8:31 
AnswerRe: MFC UI Thread vs. Background Thread Pin
Vitaly Tomilov23-Jun-12 13:17
Vitaly Tomilov23-Jun-12 13:17 
AnswerRe: MFC UI Thread vs. Background Thread Pin
fat_boy23-Jun-12 23:55
fat_boy23-Jun-12 23:55 
QuestionA Simple C++ Question. Pin
Sivaraman Dhamodharan22-Jun-12 4:19
Sivaraman Dhamodharan22-Jun-12 4:19 
AnswerRe: A Simple C++ Question. Pin
David Crow22-Jun-12 4:47
David Crow22-Jun-12 4:47 
GeneralRe: A Simple C++ Question. Pin
Sivaraman Dhamodharan26-Jun-12 0:51
Sivaraman Dhamodharan26-Jun-12 0:51 
AnswerRe: A Simple C++ Question. PinPopular
Albert Holguin22-Jun-12 5:05
professionalAlbert Holguin22-Jun-12 5:05 
AnswerRe: A Simple C++ Question. Pin
Maximilien22-Jun-12 5:26
Maximilien22-Jun-12 5:26 
AnswerRe: A Simple C++ Question. Pin
Chuck O'Toole22-Jun-12 8:21
Chuck O'Toole22-Jun-12 8:21 
GeneralRe: A Simple C++ Question. Pin
jschell22-Jun-12 13:01
jschell22-Jun-12 13:01 
AnswerRe: A Simple C++ Question. Pin
Chuck O'Toole23-Jun-12 8:58
Chuck O'Toole23-Jun-12 8:58 
GeneralRe: A Simple C++ Question. Pin
jschell24-Jun-12 12:06
jschell24-Jun-12 12:06 
AnswerRe: A Simple C++ Question. Pin
Chuck O'Toole24-Jun-12 13:29
Chuck O'Toole24-Jun-12 13:29 
GeneralRe: A Simple C++ Question. Pin
jschell25-Jun-12 9:33
jschell25-Jun-12 9:33 
GeneralRe: A Simple C++ Question. Pin
Aescleal23-Jun-12 7:36
Aescleal23-Jun-12 7:36 
AnswerRe: A Simple C++ Question. Pin
Chuck O'Toole23-Jun-12 8:58
Chuck O'Toole23-Jun-12 8:58 
GeneralRe: A Simple C++ Question. Pin
Albert Holguin22-Jun-12 10:05
professionalAlbert Holguin22-Jun-12 10:05 

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.