Timer used in Windows Services

G

Guest

Hello, friends,

I am programming a Windows Service using .net 2005. In this service, I need
a timer to check file status in a predefined interval. However, as you may
have experienced by yourself or read through internet, the
System.Timers.Timer() is not reliable: The timer event may not be fired at
all sometimes.

Any good/reliable solutions/approaches for this? Thanks a lot.
 
P

Peter Duniho

Andrew said:
I am programming a Windows Service using .net 2005. In this service, I need
a timer to check file status in a predefined interval. However, as you may
have experienced by yourself or read through internet, the
System.Timers.Timer() is not reliable: The timer event may not be fired at
all sometimes.

Any good/reliable solutions/approaches for this? Thanks a lot.

The only problem I've read about with respect to any timer problems in
..NET is a timer that has been configured to repeat, and which has been
left running for an extended period of time (I don't recall the
specifics, but "49 days" seems to pop into my head for some reason).

If your application is one that might be affected by this, my
understanding is that simply changing the timer usage so that you reset
the timer each time it is signaled, and start it again with a new
interval, it works fine.

If you expect there to be a problem, my suggestion is that you first
reproduce the problem in your own code. Then you will have a better
idea of whether it's really a problem, and you will be able to ensure
that you have satisfactorily worked around the problem.

Pete
 
G

GlennDoten

sloan said:
You should "code up" a timer.

http://groups.google.com/group/micr...heWorkTimer+As+Timer"&rnum=3#009395e3234a3dbc

I think I have a link at the bottom of that post, which refs a MS KB article
about the "why".

Isn't it just a problem in .NET 1.0 and 1.1 but not in 2.0 and later?

The KB article that is pointed to in the thread you posted says those
are the versions the bug applies to, but I wonder if it was written
before .NET 2.0 was out?

http://support.microsoft.com/kb/842793
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top