Help: Threading a timer

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

    Help: Threading a timer

    How do I put a timer in it's own thread? The reason I need this is that I
    may have like 30 timers going continuously and it's more efficient (right??)

    Thanks.


  • Cor

    #2
    Re: Threading a timer

    Hi VB programmer

    Take a look at "system.timers. timer"

    I thought that has already itself his own thread.

    And don't use forms.form.time r, that you can drag from the desinger,

    Just and advice

    Cor



    Comment

    • VB Programmer

      #3
      Re: Threading a timer

      How do I "attach" code to the timer, adjust interval properties, etc... if I
      use "system.timers. timer"?

      "Cor" <non@non.com> wrote in message
      news:3f8efdbb$1 $3936$48b97d01@ reader20.wxs.nl ...[color=blue]
      > Hi VB programmer
      >
      > Take a look at "system.timers. timer"
      >
      > I thought that has already itself his own thread.
      >
      > And don't use forms.form.time r, that you can drag from the desinger,
      >
      > Just and advice
      >
      > Cor
      >
      >
      >[/color]


      Comment

      • Cor

        #4
        Re: Threading a timer

        Hi VB programmer

        When you search on MSDN with system.timers.t imer

        You get some links

        This is one of them


        But there are furthermore a lot.

        I hope this helps,

        Cor


        Comment

        • Fergus Cooney

          #5
          Re: Threading a timer

          Hi VBP, Cor,

          Actually there are <three> sets of Timers.

          Forms.Timer is the familiar drag-n-drop one.

          System.Timers.T imer is one that can be used without a Form. It's
          similar in use in that it raises an Event to which a class in your app
          subscribes.


          lrfsystemtimers timerclassctort opic.asp

          System.Threadin g.Timer is one which you provide a callback method.
          When the Timer goes off, this method is called in its own Thread.


          lrfsystemthread ingtimerclassct ortopic2.asp

          Ok, that's the choices. There's a (typically MSDN) example with each.

          Is it more efficient? First some questions: ;-)

          What are they for?
          How often will they go off?
          Same interval for each?
          Staggered or all at once?
          What jobs will get done?
          How long will the jobs take?

          Regards,
          Fergus


          Comment

          • Cor

            #6
            Re: Threading a timer

            Hi Fergus,

            More minimal four.

            (And I don't mean datetime and things like that)

            Cor


            Comment

            • Fergus Cooney

              #7
              Re: Threading a timer

              Ho Cor,

              Lol. More? Excellent - can't have too few Timers. ;-)

              What did I miss?

              Regards,
              Fergus


              Comment

              • Cor

                #8
                OT: Re: Threading a timer

                Hi Fergus,

                I was helping someone together with OHM and then suddenly I saw a timer I
                never had seen. It was something like the Strconv function. It exist but if
                you haven't seen it and you won't believe that such a simple and small
                function exist.

                But this timer had no advantages, so I forgot it, I only did remember that
                there was another one (I hope it was not a bad dream). I did not found it
                again now by searching and I find it is to unimportant, the three you
                mentioned where the most important I think.

                But there are more timers, this I did find in a search in
                "time-to-reach-queue timer".

                I was busy a while with those timers, the problem is that espacialy the form
                and the stystem timer workint totaly different so in the documentation you
                have to watch very carefully what you are using.

                And now I use automaticly the thread.sleep, that is easy to manage and with
                an do application.eve nt you can do everything with it even in threads, but
                of course very inaccurate.
                (When I tell it how I use it I get standard a message from Herfried).

                But that is of course not good answer to an OP who ask for a timer.

                :-)
                Cor


                Comment

                • Fergus Cooney

                  #9
                  OT: Re: Threading a timer

                  Hi Cor,

                  Thanks. If that function does turn up.. well, I'm curious now. ;-)

                  ~~ I hope it was not a bad dream

                  I've been dreaming all morning (before I was fully awake) that a pizza and
                  ingredients that I got ready lat night were missing. As the dream was mixed up
                  with languages.vb thoughts, it was very strange. The pizza's still three
                  though. Maybe it's an important post that's missing.

                  I believe that the Timers use Sleep themselves. The Forms one has a
                  resolution of 55ms which is adequate for UI work. I'm not sure of the
                  Timers.Timer one. The Threading one is 1ms, as is Sleep itself. [There was a
                  query in vb.winapi from a guy who couldn't get his below 10ms. Something about
                  not setting it right - but that was WinApi not .NET]

                  Using Thread.Sleep is perfecty valid - as you say it's very
                  straightforward - and may be a better solution than using Timers so I'd put
                  the idea forward - let the OP decide. ;-)

                  Cheers,
                  Fergus


                  Comment

                  Working...