Trouble with timer
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Trouble with timer

  1. #1
    Join Date
    Jan 2013
    Posts
    44

    Trouble with timer

    Hi everybody !

    The purpose is to manage serial communication with a pedal.
    I wrote a class pedal that allows to search for the serial port on which the pedal is connected. Therefore I send a request to the pedal and set up a timer event of 20 ms. If no reply, I search for the next serial port.
    When found I send configuration to the pedal and set another timer event of 200 ms that requests for pedal state.
    It runs fine.

    Now if the pedal is disconnected then connected again I would like it to run again.
    Therefore I set another timer event every 2s that launches all what I described above.
    The trouble comes because the 20 ms timer event doesn't run and I do not understand why.
    Thanks.

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: Trouble with timer

    You'll probably get more/better help if you post the code of a minimally complete example that shows your problem.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Join Date
    Jan 2013
    Posts
    44

    Re: Trouble with timer

    Please see the code written on the thread with same title below

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,925

    Re: Trouble with timer

    If you are talking about WM_TIMER type timers.

    1) The time you specify only guarantees that you will get a timer message NO SOONER THAN the interval you specify, there is no guarantee of actual interval precision.
    2) The system does not actually generate timer messages, it merely sets a flag. Your application needs to process messages via the PeekMessage/GetMessage type functions to actually generate a WM_TIMER message (this is similar to how WM_PAINT's arrive in your application).
    3) Even if you use the callback function variant of the timer, your application needs to be processing messages to receive the callbacks.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center