Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What is the easiest way to do a timer ?

What is the easiest way to do a timer ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BeakX
    wrote on last edited by
    #1

    I am currently developing a MFC dialog based application and i need a function----- void Pause(int time) such that Pause(3); will stop a loop(or rather the whole application) for 3 seconds...Pause(n) will stop a loop for n seconds..etc. What is the easiest way to write such a function(preferebly without #including any libraries) ? I have been experimenting with some of the syntax without much success...Can some kind soul please put me out of my misery and tell me how to do it ? Thanks :)

    R R 2 Replies Last reply
    0
    • B BeakX

      I am currently developing a MFC dialog based application and i need a function----- void Pause(int time) such that Pause(3); will stop a loop(or rather the whole application) for 3 seconds...Pause(n) will stop a loop for n seconds..etc. What is the easiest way to write such a function(preferebly without #including any libraries) ? I have been experimenting with some of the syntax without much success...Can some kind soul please put me out of my misery and tell me how to do it ? Thanks :)

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Sleep(n*1000); // where n in seconds.

      ~RaGE();

      B M 2 Replies Last reply
      0
      • R Rage

        Sleep(n*1000); // where n in seconds.

        ~RaGE();

        B Offline
        B Offline
        BeakX
        wrote on last edited by
        #3

        thanks a million

        1 Reply Last reply
        0
        • R Rage

          Sleep(n*1000); // where n in seconds.

          ~RaGE();

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          Sleep will pause the whole application.


          Maximilien Lincourt Your Head A Splode - Strong Bad

          M 1 Reply Last reply
          0
          • M Maximilien

            Sleep will pause the whole application.


            Maximilien Lincourt Your Head A Splode - Strong Bad

            M Offline
            M Offline
            Mike Winter
            wrote on last edited by
            #5

            What I do is set up a timer to interupt every second, and then count the interupts. When you have got to your required count, you can the go off and do the functionality that you want to do Mike

            1 Reply Last reply
            0
            • B BeakX

              I am currently developing a MFC dialog based application and i need a function----- void Pause(int time) such that Pause(3); will stop a loop(or rather the whole application) for 3 seconds...Pause(n) will stop a loop for n seconds..etc. What is the easiest way to write such a function(preferebly without #including any libraries) ? I have been experimenting with some of the syntax without much success...Can some kind soul please put me out of my misery and tell me how to do it ? Thanks :)

              R Offline
              R Offline
              Requiem Sollar
              wrote on last edited by
              #6

              WM_TIMER This is a very easy thing to use, but is not 100% accurate. You will need SetTimer and KillTimer

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups