Click here to Skip to main content
15,895,462 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why can't I assign a variable's address to an enum? Pin
leon de boer30-Sep-16 3:22
leon de boer30-Sep-16 3:22 
QuestionWaitForSingleObject best practices Pin
ForNow27-Sep-16 14:26
ForNow27-Sep-16 14:26 
AnswerRe: WaitForSingleObject best practices Pin
leon de boer27-Sep-16 18:18
leon de boer27-Sep-16 18:18 
GeneralRe: WaitForSingleObject best practices Pin
ForNow28-Sep-16 2:18
ForNow28-Sep-16 2:18 
GeneralRe: WaitForSingleObject best practices Pin
leon de boer28-Sep-16 8:16
leon de boer28-Sep-16 8:16 
GeneralRe: WaitForSingleObject best practices Pin
ForNow28-Sep-16 11:41
ForNow28-Sep-16 11:41 
GeneralRe: WaitForSingleObject best practices Pin
ForNow28-Sep-16 15:57
ForNow28-Sep-16 15:57 
GeneralRe: WaitForSingleObject best practices Pin
leon de boer28-Sep-16 19:20
leon de boer28-Sep-16 19:20 
Yes that is a generic schema for not doing that sort of thing ... I hacked the MSDN thread sample.

When I do socket apps I do exactly the same schema I have a write thread and a read thread of exactly
the form above. The socket IO structures and objects are held in the memory block.

Basically you want your app just dealing with messages not sitting around doing things .. bring up task
manager and look at the number of threads running normally. It really expects and wants this sort of
behaviour, it's designed around it.

Lifetime of app threads in particular are extremely easy because you can launch them on the WM_CREATE
of the main app window and dispose of them in the WM_DESTROY. You don't have the problem of who is
responsible for the shared data and memory (and it's cleanup) that you have with intermittent start
and stop threads. The app window handle to pass to the thread to message you also can't get wrong Smile | :)

They give you huge blocks of message ids at WM_APP and WM_USER to allow you to do it. All those ID's
you are free to use but you might want to check MFC might use a few (that is why I jumped 100) and
they may restrict the range down a little.
In vino veritas

GeneralRe: WaitForSingleObject best practices Pin
leon de boer30-Sep-16 9:42
leon de boer30-Sep-16 9:42 
GeneralRe: WaitForSingleObject best practices Pin
ForNow30-Sep-16 9:52
ForNow30-Sep-16 9:52 
GeneralRe: WaitForSingleObject best practices Pin
Joe Woodbury24-Oct-16 14:31
professionalJoe Woodbury24-Oct-16 14:31 
GeneralRe: WaitForSingleObject best practices Pin
Joe Woodbury24-Oct-16 14:29
professionalJoe Woodbury24-Oct-16 14:29 
QuestionDevice on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 8:18
David MacKinnon27-Sep-16 8:18 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 10:41
jeron127-Sep-16 10:41 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 11:38
David MacKinnon27-Sep-16 11:38 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 11:44
jeron127-Sep-16 11:44 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 12:10
David MacKinnon27-Sep-16 12:10 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 13:28
jeron127-Sep-16 13:28 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon28-Sep-16 12:30
David MacKinnon28-Sep-16 12:30 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron129-Sep-16 4:19
jeron129-Sep-16 4:19 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:43
David MacKinnon29-Sep-16 4:43 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
leon de boer27-Sep-16 17:18
leon de boer27-Sep-16 17:18 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:45
David MacKinnon29-Sep-16 4:45 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:40
David MacKinnon29-Sep-16 4:40 
Question_tcscpy_s and unused buffer part Pin
leon de boer27-Sep-16 5:39
leon de boer27-Sep-16 5:39 

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.