System. Timers. Timer does not work properly in the Windows Services program.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.