CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Location
    Germany
    Posts
    7

    Timer-Interrupt on NT

    Hallo,

    does someone know how to program a timer interrupt on NT? My goal is to start a short function every millisecond.

    If anyone has a hint, i would be grateful.

    Markus


  2. #2
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: Timer-Interrupt on NT

    Yes, use the timer commands.

    SetTimer() will give you a timer object and a WM_TIMER will be generated when that timer is set.

    And you can use WaitForSingleObject on the timer handle (that is returned by SetTimer)




    The best things come to those who rate

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Timer-Interrupt on NT

    The standard windows timer (like 'SetTimer()') wouldn't help you in this case. They are simply not accurate enough. If you need measure within the millisecond range you need to think about other possibilities. Since the standard posts 'WM_TIMER' messages to a message queue, and you can never be sure when this message will be processed.

    In your case I would suggest using waitable timers. The main purpose of these timers is thread synchronization. They are kernel objects which will be signaled in the specified time, or in regular time intervals. They can specify the callback function (actually, an asynchronous procedure call, or APC) which gets called when timer gets signaled...there are unfortunately some downsides of these timers which reduces the usability significantly...

    Take a look at http://www.codeproject.com/system/timers_intro.asp for a overview of all available timers in windows operating systems...

    Ciao, Andreas

    "Software is like sex, it's better when it's free." - Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured