Announcement

Collapse
No announcement yet.

Pause %WM_TIMER

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pause %WM_TIMER

    How do I go about pausing the %WM_TIMER???

    All I can find is SetTimer and KillTimer, but nothing about pausing.

    I have a partially working Timer that "Pauses" by killing the timer and recreating it when I am done with my paused amount of time (time unknown till runtime), but find myself in a catch 22.....of either stuck in a continuous loop, or runs fine the 1st time but only runs half-way through the second time.

    I am out to demonstrate to the user how my program works, but at points where I wait for them to press a button, I need the timer to not fire until that function is complete.

    Is there a pause? or do I have to set another flag to ignore the timer fired while I was off doing something else????
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    Not quite sure what you are doing, but there is no 'pause.' Usually timers are just killed, then recreated when needed again.

    If you are in a loop, the problem is code structure, because your kill/set sequence is pretty much "SOP."

    But you could (if you were ambitious)...

    Use Waitable timer in its own thread (demo: Waitable Timer Object Demo June 2005)....

    ... and when the timer fires post a message to your main window.

    When you want to disable it.... THREAD SUSPEND the thread with the timer object code and THREAD RESUME to re-enable.

    It's a thought... but it sure sounds like overkill to me.

    The problem you have here might be mis-application.... timers are used to wait for a time, not a user event such as clicking a button, or waiting for a function to complete.

    To wait for a function to complete, run it from your GUI in a separate thead of execution as demo'd here in the demo I should have created years ago: GUI + Worker Thread + Abort Demo 11-24-07

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Thanx MCM....
      I thought about your Wait-able Timer object a few mins back and maybe that is the key....

      Since this a add on to a full blown program....I am going to have to go build a mini-demo of my situation.

      (and probably find another case of CNDS )

      In a case such as this...I am sure its something that I am doing wrong....either by not understanding...or by seeing the same code for so long, that I can't see an obvious problem.

      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        Just keep the timer running and toggle an entry flag (using a static variable or other method) when executing the task.

        Very easy, and by far the simplest solution
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          Maybe you don't need to re-invent the wheel.... Wink

          Comment


          • #6
            A vote for waitable timer

            I have used the waitable timer with success. Worth the time investment to understand & implement.

            (Thanks to MCM for his demos that flattened the learning curve. Or sharpened it? Whatever... )

            Regards,
            jim
            ... .... . ... . . ... ... .... . .. ... .... .. ... .... .. .... ..

            n6jah @ yahoo.com

            Comment


            • #7
              Thanks to MCM
              Hear! Hear!

              He has helped me a lot more than he knows.

              Rod
              Rod
              In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

              Comment

              Working...
              X