Timer driving me nuts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Timer driving me nuts

    Hi

    I have a timer on my form. The problem is no matter how large an interval I
    set, the timer_tick event always gets called very fast. What am I doing
    wrong?

    Thanks

    Regards


  • IdleBrain

    #2
    Re: Timer driving me nuts


    Hey John,
    R u setting the timer interval at runtime after starting the timer?
    If that is the case, set the timer interval before starting the timer.

    Hope it helps.


    John wrote:
    Hi
    >
    I have a timer on my form. The problem is no matter how large an interval I
    set, the timer_tick event always gets called very fast. What am I doing
    wrong?
    >
    Thanks
    >
    Regards

    Comment

    • John

      #3
      Re: Timer driving me nuts

      I have set it at design time and it currently stands at 600000. Still too
      fast almost like 1 second. I am running my process in the Timer_Tick event.

      Thanks

      Regards

      "IdleBrain" <indianmostwant ed@yahoo.comwro te in message
      news:1156780957 .716168.272910@ i3g2000cwc.goog legroups.com...
      >
      Hey John,
      R u setting the timer interval at runtime after starting the timer?
      If that is the case, set the timer interval before starting the timer.
      >
      Hope it helps.
      >
      >
      John wrote:
      >Hi
      >>
      >I have a timer on my form. The problem is no matter how large an interval
      >I
      >set, the timer_tick event always gets called very fast. What am I doing
      >wrong?
      >>
      >Thanks
      >>
      >Regards
      >

      Comment

      • GhostInAK

        #4
        Re: Timer driving me nuts

        Hello John,

        If I remember correctly the Timer.Interval will accept a large numer, like
        600000, however the only valid numbers are 0 through ~32000. Interval is
        defined in milliseconds.

        -Boo
        I have set it at design time and it currently stands at 600000. Still
        too fast almost like 1 second. I am running my process in the
        Timer_Tick event.
        >
        Thanks
        >
        Regards
        >
        "IdleBrain" <indianmostwant ed@yahoo.comwro te in message
        news:1156780957 .716168.272910@ i3g2000cwc.goog legroups.com...
        >
        >Hey John,
        >R u setting the timer interval at runtime after starting the timer?
        >If that is the case, set the timer interval before starting the
        >timer.
        >Hope it helps.
        >>
        >John wrote:
        >>
        >>Hi
        >>>
        >>I have a timer on my form. The problem is no matter how large an
        >>interval
        >>I
        >>set, the timer_tick event always gets called very fast. What am I
        >>doing
        >>wrong?
        >>Thanks
        >>>
        >>Regards
        >>>

        Comment

        • Stuart Nathan

          #5
          Re: Timer driving me nuts

          Can we see the code?


          Comment

          • John

            #6
            Re: Timer driving me nuts

            Got it now thanks. My only problem now is to set the interval to about 5
            minutes. If the highest interval the timer can take is 32000 (32 seconds?)
            then how does one get round it?

            Thanks again everyone.

            Regards

            "Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
            news:encbx21yGH A.5072@TK2MSFTN GP03.phx.gbl...
            Can we see the code?
            >

            Comment

            • JR

              #7
              Re: Timer driving me nuts

              from the help:
              The interval can be between 1 and 64,767, inclusive, which means that
              even the longest interval will not be much longer than one minute (about
              64.8 seconds).

              now if you need a larger timer try the following.

              Add a static variable.

              rease the variable each time you enter the sub. When you have the seconds
              you need (if - end if) do your stuff

              Jan


              "John" <John@nospam.in fovis.co.ukschr eef in bericht
              news:OrncNP3yGH A.5048@TK2MSFTN GP05.phx.gbl...
              Got it now thanks. My only problem now is to set the interval to about 5
              minutes. If the highest interval the timer can take is 32000 (32 seconds?)
              then how does one get round it?
              >
              Thanks again everyone.
              >
              Regards
              >
              "Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
              news:encbx21yGH A.5072@TK2MSFTN GP03.phx.gbl...
              >Can we see the code?
              >>
              >
              >

              Comment

              • Claes Bergefall

                #8
                Re: Timer driving me nuts

                I've never heard of a 32/64/whatever sec limitation (except on Windows 3.x).
                Both of the following works fine on my machine:

                Timer1.Interval = 60000 '1 minute interval
                Timer1.Start()

                Timer1.Interval = 300000 '5 minute interval
                Timer1.Start()


                According to the docs for SetTimer (that System.Windows. Forms.Timer uses)
                the maximum value for the interval is USER_TIMER_MAXI MUM. That constant is
                defined in winuser.h as 0x7FFFFFFF

                There must be something else that's wrong in this case. Show your code

                /claes

                "John" <John@nospam.in fovis.co.ukwrot e in message
                news:OrncNP3yGH A.5048@TK2MSFTN GP05.phx.gbl...
                Got it now thanks. My only problem now is to set the interval to about 5
                minutes. If the highest interval the timer can take is 32000 (32 seconds?)
                then how does one get round it?
                >
                Thanks again everyone.
                >
                Regards
                >
                "Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
                news:encbx21yGH A.5072@TK2MSFTN GP03.phx.gbl...
                >Can we see the code?
                >>
                >
                >

                Comment

                • Theo Verweij

                  #9
                  Re: Timer driving me nuts

                  I think there is a misunderstandin g between the readers.
                  There are 2 types of timers available:
                  1. The timer control (System.Windows .Forms.Timer)
                  2. The timer class (System.Timers. Timer)

                  The first one is a control, and has a limititation of 64,767 seconds.
                  The second one is a class, and does not have this limitation.


                  Claes Bergefall wrote:
                  I've never heard of a 32/64/whatever sec limitation (except on Windows 3.x).
                  Both of the following works fine on my machine:
                  >
                  Timer1.Interval = 60000 '1 minute interval
                  Timer1.Start()
                  >
                  Timer1.Interval = 300000 '5 minute interval
                  Timer1.Start()
                  >
                  >
                  According to the docs for SetTimer (that System.Windows. Forms.Timer uses)
                  the maximum value for the interval is USER_TIMER_MAXI MUM. That constant is
                  defined in winuser.h as 0x7FFFFFFF
                  >
                  There must be something else that's wrong in this case. Show your code
                  >
                  /claes
                  >
                  "John" <John@nospam.in fovis.co.ukwrot e in message
                  news:OrncNP3yGH A.5048@TK2MSFTN GP05.phx.gbl...
                  >Got it now thanks. My only problem now is to set the interval to about 5
                  >minutes. If the highest interval the timer can take is 32000 (32 seconds?)
                  >then how does one get round it?
                  >>
                  >Thanks again everyone.
                  >>
                  >Regards
                  >>
                  >"Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
                  >news:encbx21yG HA.5072@TK2MSFT NGP03.phx.gbl.. .
                  >>Can we see the code?
                  >>>
                  >>
                  >
                  >

                  Comment

                  • C-Services Holland b.v.

                    #10
                    Re: Timer driving me nuts

                    John wrote:
                    Got it now thanks. My only problem now is to set the interval to about 5
                    minutes. If the highest interval the timer can take is 32000 (32 seconds?)
                    then how does one get round it?
                    >
                    Thanks again everyone.
                    >
                    Regards
                    >
                    How about storing the time when you start then let the timer check every
                    second orso to check the timespan between the current time and the
                    stored start time.




                    --
                    Rinze van Huizen
                    C-Services Holland b.v

                    Comment

                    • Claes Bergefall

                      #11
                      Re: Timer driving me nuts

                      The first is a class too...

                      As I posted below I successfully used System.Windows. Forms.Timer with a 5
                      minute (i.e. 300 seconds) timeout. Can you show me where this limitation of
                      the System.Windows. Forms.Timer control is documented (beacuse I can't find
                      it)?

                      /claes

                      "Theo Verweij" <tverweij@xs4al l.nlwrote in message
                      news:%23yXHhd6y GHA.1292@TK2MSF TNGP03.phx.gbl. ..
                      >I think there is a misunderstandin g between the readers.
                      There are 2 types of timers available:
                      1. The timer control (System.Windows .Forms.Timer)
                      2. The timer class (System.Timers. Timer)
                      >
                      The first one is a control, and has a limititation of 64,767 seconds.
                      The second one is a class, and does not have this limitation.
                      >
                      >
                      Claes Bergefall wrote:
                      >I've never heard of a 32/64/whatever sec limitation (except on Windows
                      >3.x). Both of the following works fine on my machine:
                      >>
                      >Timer1.Interva l = 60000 '1 minute interval
                      >Timer1.Start ()
                      >>
                      >Timer1.Interva l = 300000 '5 minute interval
                      >Timer1.Start ()
                      >>
                      >>
                      >According to the docs for SetTimer (that System.Windows. Forms.Timer uses)
                      >the maximum value for the interval is USER_TIMER_MAXI MUM. That constant
                      >is defined in winuser.h as 0x7FFFFFFF
                      >>
                      >There must be something else that's wrong in this case. Show your code
                      >>
                      > /claes
                      >>
                      >"John" <John@nospam.in fovis.co.ukwrot e in message
                      >news:OrncNP3yG HA.5048@TK2MSFT NGP05.phx.gbl.. .
                      >>Got it now thanks. My only problem now is to set the interval to about 5
                      >>minutes. If the highest interval the timer can take is 32000 (32
                      >>seconds?) then how does one get round it?
                      >>>
                      >>Thanks again everyone.
                      >>>
                      >>Regards
                      >>>
                      >>"Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
                      >>news:encbx21y GHA.5072@TK2MSF TNGP03.phx.gbl. ..
                      >>>Can we see the code?
                      >>>>
                      >>>
                      >>

                      Comment

                      • Claes Bergefall

                        #12
                        Re: Timer driving me nuts

                        I found it in MSDN:
                        http://msdn2.microsoft.com/en-us/library/xy0zeach.aspx

                        It actually says that the timer interval is limited to max 64 seconds. Looks
                        incorrect to me though. Setting it to 2 minutes correctly fires the Tick
                        event every 2 minutes as expected in my text application. And the underlying
                        API (SetTimer) doesn't have any 64 sec limitation so why would the Timer
                        class have it?

                        /claes

                        "Claes Bergefall" <louplou@nospam .nospamwrote in message
                        news:eWgUEMEzGH A.2640@TK2MSFTN GP06.phx.gbl...
                        The first is a class too...
                        >
                        As I posted below I successfully used System.Windows. Forms.Timer with a 5
                        minute (i.e. 300 seconds) timeout. Can you show me where this limitation
                        of the System.Windows. Forms.Timer control is documented (beacuse I can't
                        find it)?
                        >
                        /claes
                        >
                        "Theo Verweij" <tverweij@xs4al l.nlwrote in message
                        news:%23yXHhd6y GHA.1292@TK2MSF TNGP03.phx.gbl. ..
                        >>I think there is a misunderstandin g between the readers.
                        >There are 2 types of timers available:
                        >1. The timer control (System.Windows .Forms.Timer)
                        >2. The timer class (System.Timers. Timer)
                        >>
                        >The first one is a control, and has a limititation of 64,767 seconds.
                        >The second one is a class, and does not have this limitation.
                        >>
                        >>
                        >Claes Bergefall wrote:
                        >>I've never heard of a 32/64/whatever sec limitation (except on Windows
                        >>3.x). Both of the following works fine on my machine:
                        >>>
                        >>Timer1.Interv al = 60000 '1 minute interval
                        >>Timer1.Start( )
                        >>>
                        >>Timer1.Interv al = 300000 '5 minute interval
                        >>Timer1.Start( )
                        >>>
                        >>>
                        >>According to the docs for SetTimer (that System.Windows. Forms.Timer
                        >>uses) the maximum value for the interval is USER_TIMER_MAXI MUM. That
                        >>constant is defined in winuser.h as 0x7FFFFFFF
                        >>>
                        >>There must be something else that's wrong in this case. Show your code
                        >>>
                        >> /claes
                        >>>
                        >>"John" <John@nospam.in fovis.co.ukwrot e in message
                        >>news:OrncNP3y GHA.5048@TK2MSF TNGP05.phx.gbl. ..
                        >>>Got it now thanks. My only problem now is to set the interval to about
                        >>>5 minutes. If the highest interval the timer can take is 32000 (32
                        >>>seconds?) then how does one get round it?
                        >>>>
                        >>>Thanks again everyone.
                        >>>>
                        >>>Regards
                        >>>>
                        >>>"Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
                        >>>news:encbx21 yGHA.5072@TK2MS FTNGP03.phx.gbl ...
                        >>>>Can we see the code?
                        >>>>>
                        >>>>
                        >>>
                        >

                        Comment

                        • Theo Verweij

                          #13
                          Re: Timer driving me nuts

                          I also don't know why, but it is documented this way.
                          Maybe a microsoft employee can explain this?


                          Claes Bergefall wrote:
                          I found it in MSDN:
                          http://msdn2.microsoft.com/en-us/library/xy0zeach.aspx
                          >
                          It actually says that the timer interval is limited to max 64 seconds. Looks
                          incorrect to me though. Setting it to 2 minutes correctly fires the Tick
                          event every 2 minutes as expected in my text application. And the underlying
                          API (SetTimer) doesn't have any 64 sec limitation so why would the Timer
                          class have it?
                          >
                          /claes
                          >
                          "Claes Bergefall" <louplou@nospam .nospamwrote in message
                          news:eWgUEMEzGH A.2640@TK2MSFTN GP06.phx.gbl...
                          >The first is a class too...
                          >>
                          >As I posted below I successfully used System.Windows. Forms.Timer with a 5
                          >minute (i.e. 300 seconds) timeout. Can you show me where this limitation
                          >of the System.Windows. Forms.Timer control is documented (beacuse I can't
                          >find it)?
                          >>
                          > /claes
                          >>
                          >"Theo Verweij" <tverweij@xs4al l.nlwrote in message
                          >news:%23yXHhd6 yGHA.1292@TK2MS FTNGP03.phx.gbl ...
                          >>I think there is a misunderstandin g between the readers.
                          >>There are 2 types of timers available:
                          >>1. The timer control (System.Windows .Forms.Timer)
                          >>2. The timer class (System.Timers. Timer)
                          >>>
                          >>The first one is a control, and has a limititation of 64,767 seconds.
                          >>The second one is a class, and does not have this limitation.
                          >>>
                          >>>
                          >>Claes Bergefall wrote:
                          >>>I've never heard of a 32/64/whatever sec limitation (except on Windows
                          >>>3.x). Both of the following works fine on my machine:
                          >>>>
                          >>>Timer1.Inter val = 60000 '1 minute interval
                          >>>Timer1.Start ()
                          >>>>
                          >>>Timer1.Inter val = 300000 '5 minute interval
                          >>>Timer1.Start ()
                          >>>>
                          >>>>
                          >>>According to the docs for SetTimer (that System.Windows. Forms.Timer
                          >>>uses) the maximum value for the interval is USER_TIMER_MAXI MUM. That
                          >>>constant is defined in winuser.h as 0x7FFFFFFF
                          >>>>
                          >>>There must be something else that's wrong in this case. Show your code
                          >>>>
                          >>> /claes
                          >>>>
                          >>>"John" <John@nospam.in fovis.co.ukwrot e in message
                          >>>news:OrncNP3 yGHA.5048@TK2MS FTNGP05.phx.gbl ...
                          >>>>Got it now thanks. My only problem now is to set the interval to about
                          >>>>5 minutes. If the highest interval the timer can take is 32000 (32
                          >>>>seconds?) then how does one get round it?
                          >>>>>
                          >>>>Thanks again everyone.
                          >>>>>
                          >>>>Regards
                          >>>>>
                          >>>>"Stuart Nathan" <stuart.nathan@ homecall.co.ukw rote in message
                          >>>>news:encbx2 1yGHA.5072@TK2M SFTNGP03.phx.gb l...
                          >>>>>Can we see the code?
                          >>>>>>
                          >
                          >

                          Comment

                          Working...