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 8015731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:20:04+00:00 2026-06-04T20:20:04+00:00

I need to create Timer in my VC++ application , at where i need

  • 0

I need to create Timer in my VC++ application , at where i need to set timer and on timeout of timer , i need to call one specific method…

i have seen msdn forums for that and done below code to do that
SetTimer(NULL,1,5*1000,TimerProc);

and my TimerProc method is as below

void CALLBACK TimerProc(HWND aHwnd, UINT aMessage, UINT_PTR aTimerId, DWORD aTime)
{
    StopProceess();
}

i assume after 5 seconds the SetTimer should call TimerProc method , but it is never called. no idea what i am doing wrong in this. or plz suggest if there’s any alternative to do it.

Thanks.

  • 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-04T20:20:06+00:00Added an answer on June 4, 2026 at 8:20 pm

    Use waitable timer. Callback will be called after time set by 5-th parameter and repeat every 6-th parameter.
    After time elapses, callback is called, executes some processing and sets event to allow exit

        // ConsoleTimer.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    #define TIME_LAPS 5 * 1000
    
    HANDLE g_hExitEvent = NULL;
    
    
    void CALLBACK WaitOrTimerCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
    {
            Sleep(5000); // fake long processing
            SetEvent(g_hExitEvent);
    }
    
    int _tmain(int argc, _TCHAR* argv[])
    {
            HANDLE hNewTimer = NULL;                                                                                                                        //call after
            BOOL IsCreated = CreateTimerQueueTimer(&hNewTimer, NULL, WaitOrTimerCallback, NULL, TIME_LAPS, 
                    // repeat
                    TIME_LAPS, WT_EXECUTELONGFUNCTION);
    
            g_hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    
            WaitForSingleObject(g_hExitEvent, 15000);
    
            DeleteTimerQueueTimer(NULL, hNewTimer, NULL);
    
            return 0;
    }
    

    I do not check for errors, you should.

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

Sidebar

Related Questions

I need to create an interval Timer that is set to run once a
I have a one-time need to create a file from an iOS mutable array.
I have an application that allows for users to create questions, create answers to
I need to create a GUI application with Tkinter that requires a lot of
I have a Silverlight application that I need to embed some less-than-common fonts in.
I need to create TCP/IP headers manually for my application. For that i used
I have a unique set of processes that all need to be automated. We
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
I have written an application that unit tests our hardware via a internet browser.
I have been task with (ha) creating an application that will allow the users

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.