人是有惰性的

想到哪儿写到哪儿
BUG: The Elapsed event of the System.Timers.Timer class is not raised in a Windows service
转:http://support.microsoft.com/?scid=kb%3Ben-us%3B842793&x=13&y=8

SYMPTOMS

You can use the Microsoft .NET Framework to create a new Microsoft Windows service that contains a System.Timers.Timer object. When you run this new Windows service, the Elapsed event of the System.Timers.Timer class may not be raised.

Back to the top

CAUSE

Note In this section, the System.Timers.Timer object is referred to as the Timer object.

In the event handler for the Elapsed event of the Timer object, if you call the Stop method of the Timer object, the reference to the Timer object is lost. The garbage collector then reclaims the memory that is associated with the Timer object. Later, even if you call the Start method of the Timer object to raise the Elapsed event, the call does not work. The Elapsed event is not raised.

Back to the top

WORKAROUND

To work around this problem, obtain the hotfix in the following Microsoft Knowledge Base article:
900822 (http://support.microsoft.com/kb/900822/) FIX: When a .NET Framework based application uses the System.Threading.Timer class, the timer event may not be signaled in the .NET Framework 1.1 S900822
Additionally, use a System.Threading.Timer object instead of the System.Timers.Timer object.

posted on 2007-08-02 13:32  guanfei  阅读(241)  评论(0)    收藏  举报