Timers

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

    Timers

    I want to Start a process in a Service
    once a Week

    Whats the Best Way to Handle this

    I have A completed Service with Threading Manager
    But I dont know the Best way to Start a Process
    on a Given Day...only once on That Day if Success
    if Failure ..then Try Again

    Tks
    DaveL


  • Peter Duniho

    #2
    Re: Timers

    On Sat, 14 Jun 2008 10:44:28 -0700, daveL <vettes_n_jets@ yahoo.comwrote:
    I want to Start a process in a Service
    once a Week
    >
    Whats the Best Way to Handle this
    Why not use a Timer class? System.Timers.T imer or System.Threadin g.Timer
    would seem appropriate for a service.

    Pete

    Comment

    • daveL

      #3
      Re: Timers

      I am Using System.Timer
      Where im having a problem is
      Iim not sure how to
      go about having this fire once a week and only run once
      on a specified Day

      Any advice
      Thanks DaveL


      "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
      news:op.ucribiv z8jd0ej@petes-computer.local. ..
      On Sat, 14 Jun 2008 10:44:28 -0700, daveL <vettes_n_jets@ yahoo.comwrote:
      >
      >I want to Start a process in a Service
      >once a Week
      >>
      >Whats the Best Way to Handle this
      >
      Why not use a Timer class? System.Timers.T imer or System.Threadin g.Timer
      would seem appropriate for a service.
      >
      Pete

      Comment

      • Peter Duniho

        #4
        Re: Timers

        On Sat, 14 Jun 2008 17:17:09 -0700, daveL <vettes_n_jets@ yahoo.comwrote:
        I am Using System.Timer
        There's no such class. Do you mean System.Timers.T imer?
        Where im having a problem is
        Iim not sure how to
        go about having this fire once a week and only run once
        on a specified Day
        What problem are you having? What about the goal aren't you sure about?
        Are you having trouble calculating the number of milliseconds in a week?
        Is your code for some reason running the timer elapsed handler more than
        once in a day, in spite of having set the interval to a week?

        Your question is extremely vague. You really will need to state your
        question more clearly to get a useful reply.

        Pete

        Comment

        • daveL

          #5
          Re: Timers

          Im not explaining myself well , because im unsure how to approach this

          so do i set the interval to x amount of milliseconds based on milliseconds
          in a 24 hour period
          then check if its the day i want

          also if time to run is involved do i set the timer to lets say hourly and
          how to make it precise on the time required to run

          the thread is running perfect i just dont have it running like i need
          yet....

          i hope the above helps..
          Thanks DaveL

          much appriciated


          "daveL" <vettes_n_jets@ yahoo.comwrote in message
          news:33Z4k.4043 $L_.3915@flpi15 0.ffdc.sbc.com. ..
          >I am Using System.Timer
          Where im having a problem is
          Iim not sure how to
          go about having this fire once a week and only run once
          on a specified Day
          >
          Any advice
          Thanks DaveL
          >
          >
          "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
          news:op.ucribiv z8jd0ej@petes-computer.local. ..
          >On Sat, 14 Jun 2008 10:44:28 -0700, daveL <vettes_n_jets@ yahoo.com>
          >wrote:
          >>
          >>I want to Start a process in a Service
          >>once a Week
          >>>
          >>Whats the Best Way to Handle this
          >>
          >Why not use a Timer class? System.Timers.T imer or System.Threadin g.Timer
          >would seem appropriate for a service.
          >>
          >Pete
          >
          >

          Comment

          • Peter Duniho

            #6
            Re: Timers

            On Sat, 14 Jun 2008 17:36:41 -0700, daveL <vettes_n_jets@ yahoo.comwrote:
            Im not explaining myself well , because im unsure how to approach this
            >
            so do i set the interval to x amount of milliseconds based on
            milliseconds
            in a 24 hour period
            then check if its the day i want
            You could. But why not just set the interval to the number of
            milliseconds in a week?
            also if time to run is involved do i set the timer to lets say hourly and
            how to make it precise on the time required to run
            How precise do you need it to be?

            It seems to me your best bet is to determine the exact time in the future
            you want the timer to execute, calculate the difference between that exact
            time and "now", and then use the result of that as the timer delay for a
            one-shot timer.

            Elapsed time calculation might look like:

            DateTime dtEvent = /* initialized to some specific date/time */
            TimeSpan tsDelay = dtEvent - DateTime.Now;

            Then the milliseconds are "tsDelay.TotalM illiseconds". Assuming you're
            using a timer that requires setting in milliseconds, set this for the
            elapsed time for the timer and start the timer. It will fire when the
            elapsed time has expired. (Obviously for a timer class that accepts a
            TimeSpan value, you don't need to use the TotalMillisecon ds property to
            convert to milliseconds :) ).

            Each timer class has a slightly different syntax for configuring it as a
            one-shot timer, so without knowing what class you're using, it's not
            possible to say for sure what you would want to do. But, for example, the
            System.Timers.T imer class has an AutoReset property which, when set to
            false, causes the timer to fire just once. It won't fire again until you
            specifically start it again.

            Finally, a week is a long time. Obviously you may want to include some
            means of re-enabling the timer in case your process exits and is restarted
            before the timer fires. This is just a special case of the above
            calculation, where the "specific date/time" is the same as it was before,
            but of course DateTime.Now returns a new value. :)
            the thread is running perfect i just dont have it running like i need
            yet....
            No offense intended, but that sentence seems self-contradictory. :)

            Pete

            Comment

            • daveL

              #7
              Re: Timers

              about my last sentence....lol I know...
              what i meant was i just set the timer to 30 seconds while testing the
              threading
              so i can make sure all is running correctly, stored procs , processing,
              updating etc

              now i need to re think the timers on running the way they need to run

              1 time once a week at a given time....

              I thank you very much for your time and effort
              DaveP

              "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
              news:op.ucrlpky t8jd0ej@petes-computer.local. ..
              On Sat, 14 Jun 2008 17:36:41 -0700, daveL <vettes_n_jets@ yahoo.comwrote:
              Im not explaining myself well , because im unsure how to approach this
              >
              so do i set the interval to x amount of milliseconds based on
              milliseconds
              in a 24 hour period
              then check if its the day i want
              You could. But why not just set the interval to the number of
              milliseconds in a week?
              also if time to run is involved do i set the timer to lets say hourly and
              how to make it precise on the time required to run
              How precise do you need it to be?

              It seems to me your best bet is to determine the exact time in the future
              you want the timer to execute, calculate the difference between that exact
              time and "now", and then use the result of that as the timer delay for a
              one-shot timer.

              Elapsed time calculation might look like:

              DateTime dtEvent = /* initialized to some specific date/time */
              TimeSpan tsDelay = dtEvent - DateTime.Now;

              Then the milliseconds are "tsDelay.TotalM illiseconds". Assuming you're
              using a timer that requires setting in milliseconds, set this for the
              elapsed time for the timer and start the timer. It will fire when the
              elapsed time has expired. (Obviously for a timer class that accepts a
              TimeSpan value, you don't need to use the TotalMillisecon ds property to
              convert to milliseconds :) ).

              Each timer class has a slightly different syntax for configuring it as a
              one-shot timer, so without knowing what class you're using, it's not
              possible to say for sure what you would want to do. But, for example, the
              System.Timers.T imer class has an AutoReset property which, when set to
              false, causes the timer to fire just once. It won't fire again until you
              specifically start it again.

              Finally, a week is a long time. Obviously you may want to include some
              means of re-enabling the timer in case your process exits and is restarted
              before the timer fires. This is just a special case of the above
              calculation, where the "specific date/time" is the same as it was before,
              but of course DateTime.Now returns a new value. :)
              the thread is running perfect i just dont have it running like i need
              yet....
              No offense intended, but that sentence seems self-contradictory. :)

              Pete


              Comment

              Working...