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. I want a Timer fuction on Non UI thread

I want a Timer fuction on Non UI thread

Scheduled Pinned Locked Moved C / C++ / MFC
design
9 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I have a application in which i need a timer event to fire at some regular interval say 1 to 10 seconds. But durint this interval other Buttons on the Dialogbox are not responing . So i want a method were i can call this timer function by which it runs on non UI thread. any idea thank you

    W R B P 4 Replies Last reply
    0
    • A Anonymous

      I have a application in which i need a timer event to fire at some regular interval say 1 to 10 seconds. But durint this interval other Buttons on the Dialogbox are not responing . So i want a method were i can call this timer function by which it runs on non UI thread. any idea thank you

      W Offline
      W Offline
      willy_total
      wrote on last edited by
      #2

      You can use CreateWaitableTimer. It will create a timer that uses events.

      R 1 Reply Last reply
      0
      • A Anonymous

        I have a application in which i need a timer event to fire at some regular interval say 1 to 10 seconds. But durint this interval other Buttons on the Dialogbox are not responing . So i want a method were i can call this timer function by which it runs on non UI thread. any idea thank you

        R Offline
        R Offline
        RaajaOfSelf
        wrote on last edited by
        #3

        If you feel teh timer function takes alot of time .then You can do this . Wherever_Timer_creation_required { setTimer(X,Y,MULL) pthread=AfxCreateThread(); } OnTimer() { pthread->PostThreadMessage(Message) } Now you can handle that message in pthread . Cause is my effort; Effect is God's effort

        1 Reply Last reply
        0
        • W willy_total

          You can use CreateWaitableTimer. It will create a timer that uses events.

          R Offline
          R Offline
          RaajaOfSelf
          wrote on last edited by
          #4

          I Guess using CreateWaitableTimer with SetTimer and WaitForSingleObject may block ur thread ! Cause is my effort; Effect is God's effort

          W 1 Reply Last reply
          0
          • A Anonymous

            I have a application in which i need a timer event to fire at some regular interval say 1 to 10 seconds. But durint this interval other Buttons on the Dialogbox are not responing . So i want a method were i can call this timer function by which it runs on non UI thread. any idea thank you

            B Offline
            B Offline
            bugDanny
            wrote on last edited by
            #5

            Use SetTimer() and OnTimer() Danny The stupidity of others amazes me!

            1 Reply Last reply
            0
            • A Anonymous

              I have a application in which i need a timer event to fire at some regular interval say 1 to 10 seconds. But durint this interval other Buttons on the Dialogbox are not responing . So i want a method were i can call this timer function by which it runs on non UI thread. any idea thank you

              P Offline
              P Offline
              PJ Arends
              wrote on last edited by
              #6

              SetTimer will work just fine. Pass NULL as the HWND and specify a TimerProc callback function.


              "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

              A 1 Reply Last reply
              0
              • P PJ Arends

                SetTimer will work just fine. Pass NULL as the HWND and specify a TimerProc callback function.


                "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                Thanks but i have already tried the SetTimer i have only one option that i didnot wanted to opt that is create a thread. :cool:

                P 1 Reply Last reply
                0
                • A Anonymous

                  Thanks but i have already tried the SetTimer i have only one option that i didnot wanted to opt that is create a thread. :cool:

                  P Offline
                  P Offline
                  PJ Arends
                  wrote on last edited by
                  #8

                  Ok, I misunderstood your question. I thought you were wondering how to set up a timer in a non-ui thread that did not have a window available to handle the WM_TIMER message. If your timer function is so lengthy that it interferes with the responsiveness of the UI then your only option is to use a seperate thread for it.


                  "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

                  1 Reply Last reply
                  0
                  • R RaajaOfSelf

                    I Guess using CreateWaitableTimer with SetTimer and WaitForSingleObject may block ur thread ! Cause is my effort; Effect is God's effort

                    W Offline
                    W Offline
                    willy_total
                    wrote on last edited by
                    #9

                    You can't use WaitForSingleObject you have to use MsgWaitForMultipleObjects then Dispatch the message to the other controls while you wait on the timer.

                    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