Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:34:18+00:00 2026-06-12T05:34:18+00:00

I spent some time trying to research a definitive answer for this and couldn’t

  • 0

I spent some time trying to research a definitive answer for this and couldn’t find a reliable source.

My scenario is fairly straightforward. I have a thread with a message pump setup that is processing a recurring event from a timer. Here is the message pump source:

// create timer that goes off every 500 ms
UINT_PTR myTimerID = SetTimer(NULL, 0, 500, TimerCallback);

// message structure
MSG msg;

// process and handle messages for this thread
BOOL getMessageStatus;
while((getMessageStatus = GetMessage(&msg, NULL, 0, 0)) != 0)
{
    // failed get message
    if(getMessageStatus == -1)
    {
        printf("GetMessage FAILED!\n");
    }
    // process timer message
    else if(msg.message == WM_TIMER)
    {
        // invoke callback
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

If TimerCallback takes longer than 500 ms, the timer will have fired its event again. Since, the callback is being executed on the same thread as the message pump, I assume that the callback must complete before the next timer message is processed by the message pump.

Is that correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:34:19+00:00Added an answer on June 12, 2026 at 5:34 am

    SetTimer() is a message-based timer. When the timer elapses, it sets a special flag inside the message queue. When you pump the queue for new messages, a WM_TIMER message will be created if that flag has been set and other higher-priority messages are not waiting in the queue. While your code is busy dispatching a generated WM_TIMER message, the timer can elapse in the background and set the flag again, generating a new WM_TIMER message the next time you pump the queue for messages. So be careful about pumping messages while inside the callback, either directly or via modal dialogs, as that can potentially lead to recursive calls of your timer callback and thus may cause a stack overflow over time. But if your message pumping is only in your main thread loop then you will be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I spent some time trying to figure out why this query isn't pulling the
I've spent some time trying to find a way CodeRush could add using when
I've spent some time trying to find an elegant and cross browser solution but
yesterday I spent some time trying to find a bug. Long story short, finally
I spent some time this morning trying to help a colleague with an odd
I spent some time trying to get working this SELECT with CASE but I
I recently spent some time trying to write some numbers as bytes to pipe
New to MVC3 Razor - linq to sql having spent some time trying to
I spent some time looking around, and all I could find is Jython. It's
I've spent some time today playing with getting the source for python 3.1.1 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.