Timer in Windows Service fires eratically when interval elapsed

Discussion in 'ASP .Net' started by Roland, Sep 8, 2004.

  1. Roland

    Roland Guest

    Hi,

    I have written a Windows Service with a Timer (System).
    The Interval is set to 60000 (60 seconds) for testing.
    In the Timer1_Elapsed event I execute a task.

    In this case I have to read a text file, draw data from a SQL server,
    and send it all out in an email every day at the same time.

    Problem is that the elapsed event fires anywhere from 1 time to 40
    times per interval. Subsequently, my task runs n times.

    Is it possible to have it fire only once?
    Or, stop it from firing until the next interval?

    Thank you!

    Roland
    Roland, Sep 8, 2004
    #1
    1. Advertising

  2. Roland

    Rutger Smit Guest

    Roland wrote:

    > Hi,
    >
    > I have written a Windows Service with a Timer (System).
    > The Interval is set to 60000 (60 seconds) for testing.
    > In the Timer1_Elapsed event I execute a task.
    >
    > In this case I have to read a text file, draw data from a SQL server,
    > and send it all out in an email every day at the same time.
    >
    > Problem is that the elapsed event fires anywhere from 1 time to 40
    > times per interval. Subsequently, my task runs n times.
    >
    > Is it possible to have it fire only once?
    > Or, stop it from firing until the next interval?
    >
    > Thank you!
    >
    > Roland


    I've had some arguments with the System.Timer but I've also built a
    stable service that runs for about a year based on the System.Timer.

    I suggest to take a look at the System.Threading.Timer, a little bit
    more complex nut very reliable.

    Just Google 'MSDN System.Threading.Timer' and check out the reference.

    --

    //Rutger

    DoDotNet@KICKTHIS_Gmail.com
    www.RutgerSmit.com
    Rutger Smit, Sep 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski

    Timer.Elapsed event doesn't want to fire

    Nathan Sokalski, Jul 15, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,907
    Peter Bromberg [C# MVP]
    Jul 17, 2005
  2. Nathan Sokalski

    Timer.Elapsed event doesn't want to fire

    Nathan Sokalski, Jul 15, 2005, in forum: ASP .Net Building Controls
    Replies:
    5
    Views:
    161
    Peter Bromberg [C# MVP]
    Jul 17, 2005
  3. Nathan Sokalski

    Timer.Elapsed event doesn't want to fire

    Nathan Sokalski, Jul 15, 2005, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    137
    Peter Bromberg [C# MVP]
    Jul 17, 2005
  4. Replies:
    3
    Views:
    990
  5. rutherf
    Replies:
    2
    Views:
    420
    rutherf
    Oct 28, 2006
Loading...

Share This Page