Problem:
In Windows ServiceProgramThe timer does not work after running for a period of time.
Analysis:
After reading a large amount of information, we found that the cause of this error was. NET FrameworkMediumSystem. Timers. TimerOfBug. The following isBugSimple information:
BUG: The elapsed event of the system. timers. timer class is not raised in a Windows Service
Article ID |
: |
kb 842793 |
last review |
: |
July 27,200 4 |
revision |
: |
1.0 |
Symptoms
You can use the Microsoft. NET Framework to create a new Microsoft Windows service that containsSystem. Timers. TimerObject. When you run this new Windows Service,ElapsedEvent ofSystem. Timers. TimerClass may not be raised.
Cause
NoteIn this section,System. Timers. TimerObject is referred to asTimerObject.
In the event handler forElapsedEvent ofTimerObject, if you callStopMethod ofTimerObject, the reference toTimerObject is lost. The Garbage Collector then reclaims the memory that is associated withTimerObject. Later, even if you callStartMethod ofTimerObject To raiseElapsedEvent, the call does not work.ElapsedEvent is not raised.
Workaround
To work around this problem, useSystem. Threading. TimerObject instead ofSystem. Timers. TimerObject.
Status
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "applies to" section.
For details, see the following link,Http://support.microsoft.com/default.aspx? SCID = KB; en-US; 842793.
Solution:
FollowKB 842793Suggestions, useSystem. Threading. TimerReplaceSystem. Timers. Timer.