Overlapping timer notificatoins?

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

    Overlapping timer notificatoins?

    If I have a long task to do in my timer event, how can I properlystop
    my timer again being notified again while I am still processing?

    Thanks.

    Adam

  • Nathan Kovac

    #2
    Re: Overlapping timer notificatoins?

    I am not sure I completely understand your question. See if this helps at
    all.

    You can have many timers running at once. If you use System.Timers you use
    the Elapsed event to run your code in if you are using System.Windows. Forms
    for your timers you use use use the Tick event.

    If you want to make your code run without holding up the rest of your
    application you can use System.Threadin g inside your Tick or Elapsed event
    handler.

    If you want to make your new thread pause so it doesn't use cpu for a while
    you can do so with the thread.Sleep function.

    I don't know much about what you are trying to do inside of the thread, but
    please note that there are some things that don't play nice when in a
    thread.

    Hope this helps,
    Nathan

    "Adam" <adam2001usa@ho tmail.com> wrote in message
    news:1118968961 .500720.34050@o 13g2000cwo.goog legroups.com...[color=blue]
    > If I have a long task to do in my timer event, how can I properlystop
    > my timer again being notified again while I am still processing?
    >
    > Thanks.
    >
    > Adam
    >[/color]


    Comment

    • Adam

      #3
      Re: Overlapping timer notificatoins?

      Let me clarify with an extreme example. Say I only have 1 timer, set
      to fire off at intervals of one minute.

      Say in the first invocation, I do some database work which takes two
      minutes to complete. During that, I'll get a second timer message (in
      the same timer) which I don't want.

      How can I stop this?

      Thanks.

      Nathan Kovac wrote:[color=blue]
      > I am not sure I completely understand your question. See if this helps at
      > all.
      >
      > You can have many timers running at once. If you use System.Timers you use
      > the Elapsed event to run your code in if you are using System.Windows. Forms
      > for your timers you use use use the Tick event.
      >
      > If you want to make your code run without holding up the rest of your
      > application you can use System.Threadin g inside your Tick or Elapsed event
      > handler.
      >
      > If you want to make your new thread pause so it doesn't use cpu for a while
      > you can do so with the thread.Sleep function.
      >
      > I don't know much about what you are trying to do inside of the thread, but
      > please note that there are some things that don't play nice when in a
      > thread.
      >
      > Hope this helps,
      > Nathan
      >
      > "Adam" <adam2001usa@ho tmail.com> wrote in message
      > news:1118968961 .500720.34050@o 13g2000cwo.goog legroups.com...[color=green]
      > > If I have a long task to do in my timer event, how can I properlystop
      > > my timer again being notified again while I am still processing?
      > >
      > > Thanks.
      > >
      > > Adam
      > >[/color][/color]

      Comment

      Working...