Click here to Skip to main content
15,915,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: private instance of a public struct Pin
elephantstar19-Oct-04 6:33
elephantstar19-Oct-04 6:33 
GeneralLinking Unicode and non-Unicode DLLs in same .EXE Pin
EurekaJim15-Oct-04 8:31
EurekaJim15-Oct-04 8:31 
GeneralRe: Linking Unicode and non-Unicode DLLs in same .EXE Pin
Blake Miller15-Oct-04 9:30
Blake Miller15-Oct-04 9:30 
GeneralRe: Linking Unicode and non-Unicode DLLs in same .EXE Pin
EurekaJim15-Oct-04 9:50
EurekaJim15-Oct-04 9:50 
GeneralRe: Linking Unicode and non-Unicode DLLs in same .EXE Pin
Blake Miller15-Oct-04 9:59
Blake Miller15-Oct-04 9:59 
GeneralSafer Timer Thread termination Pin
15-Oct-04 8:26
suss15-Oct-04 8:26 
GeneralRe: Safer Timer Thread termination Pin
Doug Mitchell15-Oct-04 9:05
Doug Mitchell15-Oct-04 9:05 
GeneralRe: Safer Timer Thread termination Pin
Blake Miller15-Oct-04 9:38
Blake Miller15-Oct-04 9:38 
I was thinking that the problem could be solved with another safety check.
Make sure the window exists before posting the message!

if( ::IsWindow(m_hWnd) ){
PostMessage (UWM_TIMER_SECOND);
}

Note that you want to invoke the GLOBAL IsWindow and not the class-specific override, that is whyt he :: is in front of the function name.

Now, you avoid your crash, and some other issue you might not have discovered yet.

I always make sure the target window still exists before posting or sending a mesage from a different thread.

Now, if you waited on an event and sets its timeout to 1000 milliseconds, you could signal the event from your main thread, and the timer thread could exit sooner (instead of always being asleep for 1 second).
If you see WAIT_OBJECT_0 you exit the thread, otherwise, if it gets WAIT_TIMEOUT, you just post your message as normal. This way, your main app would not necessarily need to wait 4 seconds, it could exit immediately.

Also, a s the other person suggests, you can wait on the timer thread handle in the main thread to know when the timer thread was done.


Generalconversion operator not being called for both objects Pin
lino_i15-Oct-04 6:53
lino_i15-Oct-04 6:53 
GeneralRe: conversion operator not being called for both objects Pin
David Crow15-Oct-04 8:09
David Crow15-Oct-04 8:09 
GeneralRe: conversion operator not being called for both objects Pin
lino_i15-Oct-04 8:37
lino_i15-Oct-04 8:37 
GeneralRe: conversion operator not being called for both objects Pin
David Crow15-Oct-04 9:03
David Crow15-Oct-04 9:03 
GeneralRe: conversion operator not being called for both objects Pin
lino_i15-Oct-04 9:25
lino_i15-Oct-04 9:25 
GeneralRe: conversion operator not being called for both objects Pin
David Crow15-Oct-04 9:46
David Crow15-Oct-04 9:46 
GeneralRe: conversion operator not being called for both objects Pin
lino_i15-Oct-04 9:50
lino_i15-Oct-04 9:50 
GeneralRe: conversion operator not being called for both objects Pin
David Crow15-Oct-04 9:59
David Crow15-Oct-04 9:59 
GeneralSkinned dialogs Pin
mtzlplyk15-Oct-04 6:14
mtzlplyk15-Oct-04 6:14 
Generalanalyzing the return value Pin
lino_i15-Oct-04 5:56
lino_i15-Oct-04 5:56 
GeneralRe: analyzing the return value Pin
mtzlplyk15-Oct-04 6:11
mtzlplyk15-Oct-04 6:11 
GeneralRe: analyzing the return value Pin
David Crow15-Oct-04 8:01
David Crow15-Oct-04 8:01 
QuestionHow do I gray out a radio button? Pin
tpbzdw15-Oct-04 5:13
tpbzdw15-Oct-04 5:13 
AnswerRe: How do I gray out a radio button? Pin
David Crow15-Oct-04 5:38
David Crow15-Oct-04 5:38 
GeneralRe: How do I gray out a radio button? Pin
tpbzdw15-Oct-04 5:41
tpbzdw15-Oct-04 5:41 
AnswerRe: How do I gray out a radio button? Pin
mtzlplyk15-Oct-04 6:04
mtzlplyk15-Oct-04 6:04 
GeneralRe: How do I gray out a radio button? Pin
tpbzdw15-Oct-04 11:35
tpbzdw15-Oct-04 11:35 

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.