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

C / C++ / MFC

 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
<k>Andreas Hoheisel6-Sep-01 8:48
<k>Andreas Hoheisel6-Sep-01 8:48 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
RobJones6-Sep-01 9:19
RobJones6-Sep-01 9:19 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
Steen Krogsgaard6-Sep-01 22:17
Steen Krogsgaard6-Sep-01 22:17 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
A.R.6-Sep-01 11:30
A.R.6-Sep-01 11:30 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
RobJones6-Sep-01 11:51
RobJones6-Sep-01 11:51 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
A.R.6-Sep-01 14:40
A.R.6-Sep-01 14:40 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
6-Sep-01 15:13
suss6-Sep-01 15:13 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
Steen Krogsgaard6-Sep-01 21:11
Steen Krogsgaard6-Sep-01 21:11 
Hi A.R.

Your solution to Rob's recursive call problem is of course absolutely correct. However, I don't think Rob's got a re-entrance problem.

>On the other hand, the timer has been set to signal every one second, and in the code where you are handling this event, there is no way to stop the messaging system sending the signal every one second, and here is where meanwhile you are decrementing your variable and formatting your display, another call has been made and so on.

Rob is handling the WM_TIMER message, and while the program is in OnTimer it will not get new messages from the message queue and hence OnTimer will not be called again. Only when Rob returns from OnTimer will a new WM_TIMER message be dispatched. So while a steady stream of WM_TIMER messages will certainly make the application seem unresponsive, it will not lead to any concurrency issues. Furthermore, WM_TIMER messages are handled in a similar manner to WM_PAINT - they are low-priority and will only be handled if the message queue is empty, and multiple WM_TIMER messages in the queue will be merged into one message. And there is no way to find out just how may WM_TIMER messages got zapped. That's why you cannot use timers to make a good clock - you'll have to read the system time inside OnTimer, and cannot rely on exactly 1 second between WM_TIMER messages (not even on average over a period of time). And don't take my word for it - it's all described in Petzold chapter 7.

>One good rule is if your timer's handler do a lot of work and the timer's period is short, you have to tell the messaging system "give me a break".
This is actually very good advice, but only for responsivity-reasons, not for concurrency.

Cheers
Steen.

"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
QuestionWhat happened? :(( Pin
Cathy5-Sep-01 12:17
Cathy5-Sep-01 12:17 
AnswerRe: What happened? :(( Pin
Christian Graus5-Sep-01 13:38
protectorChristian Graus5-Sep-01 13:38 
GeneralRe: What happened? :(( Pin
Cathy6-Sep-01 6:27
Cathy6-Sep-01 6:27 
GeneralRe: What happened? :(( Pin
Christian Graus6-Sep-01 12:10
protectorChristian Graus6-Sep-01 12:10 
Generalcapturing OutputDebugStrings Pin
Steve The Plant5-Sep-01 11:02
Steve The Plant5-Sep-01 11:02 
GeneralRe: capturing OutputDebugStrings Pin
Tomasz Sowinski6-Sep-01 1:57
Tomasz Sowinski6-Sep-01 1:57 
GeneralRe: capturing OutputDebugStrings Pin
reiko6-Sep-01 18:39
reiko6-Sep-01 18:39 
GeneralRe: capturing OutputDebugStrings Pin
Mike Nordell7-Sep-01 10:59
Mike Nordell7-Sep-01 10:59 
QuestionHow to display image in View? Pin
Jerry Wang5-Sep-01 9:18
Jerry Wang5-Sep-01 9:18 
AnswerRe: How to display image in View? Pin
Chris Losinger5-Sep-01 10:32
professionalChris Losinger5-Sep-01 10:32 
AnswerRe: How to display image in View? Pin
Not Active5-Sep-01 10:42
mentorNot Active5-Sep-01 10:42 
GeneralBSTR parameter to Stored Procedure Pin
Bigge5-Sep-01 8:46
Bigge5-Sep-01 8:46 
GeneralRe: BSTR parameter to Stored Procedure Pin
Not Active5-Sep-01 10:26
mentorNot Active5-Sep-01 10:26 
GeneralRe: BSTR parameter to Stored Procedure Pin
Rashid Thadha5-Sep-01 11:52
Rashid Thadha5-Sep-01 11:52 
GeneralTooltips Pin
5-Sep-01 7:40
suss5-Sep-01 7:40 
GeneralRe: Tooltips Pin
Rashid Thadha5-Sep-01 11:53
Rashid Thadha5-Sep-01 11:53 
GeneralRe: Tooltips Pin
6-Sep-01 6:56
suss6-Sep-01 6:56 

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.