473,569 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net Timer Issue

I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.

I can convert the project to .Net Framework 2.0, but I am unsure
whether or not this will resolve the issue.

Any ideas would be helpful.

Thank you.

Dec 26 '06 #1
10 4261
Why do I think the actual problem occurs at 49.7 days. This is a known
issue with 32 bit windows (2^31-1 milliseconds is about 49.7 days). It's
not that the timer service stops, it's that the internal timers wrap back to
zero and the trigger doesn't occur anymore. The work around is to track
what day or month it is (numeric day of month or month of year is
sufficient) Here's an example workaround.

Module Module1
Public ReadOnly Interval As New System.TimeSpan (1, 0, 0)
Public t As New System.Timers.T imer(Interval.M illiseconds)
Public MonthNumber As Integer = Today.Month

Sub Main()
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End Sub

Private Sub t_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs )
If MonthNumber <Today.Month Then
RemoveHandler t.Elapsed, AddressOf t_Elapsed
MonthNumber = Today.Month
t = New System.Timers.T imer(Interval.M illiseconds)
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End If

' Proceess timer event
End Sub

End Module
Mike Ober.

"igor" <jo********@yah oo.comwrote in message
news:11******** **************@ a3g2000cwd.goog legroups.com...
>I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.

I can convert the project to .Net Framework 2.0, but I am unsure
whether or not this will resolve the issue.

Any ideas would be helpful.

Thank you.

Dec 27 '06 #2
Michael,
Thank you for your help. I have a couple of questions. Why is it
that resetting the timer variable to a new instance every month fixes
the issue? If the System.Timers.T imer class elapsed events fire when
the internal timer reaches a specific future time value, than wouldn't
any elapsed event set to fire after the 49.7 day point fail?

As I understand it, the internal timer you mention is the timer which
starts when the server is rebooted and increments until the 49.7 day
point is reached.

Thanks again

Michael D. Ober wrote:
Why do I think the actual problem occurs at 49.7 days. This is a known
issue with 32 bit windows (2^31-1 milliseconds is about 49.7 days). It's
not that the timer service stops, it's that the internal timers wrap back to
zero and the trigger doesn't occur anymore. The work around is to track
what day or month it is (numeric day of month or month of year is
sufficient) Here's an example workaround.

Module Module1
Public ReadOnly Interval As New System.TimeSpan (1, 0, 0)
Public t As New System.Timers.T imer(Interval.M illiseconds)
Public MonthNumber As Integer = Today.Month

Sub Main()
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End Sub

Private Sub t_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs )
If MonthNumber <Today.Month Then
RemoveHandler t.Elapsed, AddressOf t_Elapsed
MonthNumber = Today.Month
t = New System.Timers.T imer(Interval.M illiseconds)
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End If

' Proceess timer event
End Sub

End Module
Mike Ober.

"igor" <jo********@yah oo.comwrote in message
news:11******** **************@ a3g2000cwd.goog legroups.com...
I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.

I can convert the project to .Net Framework 2.0, but I am unsure
whether or not this will resolve the issue.

Any ideas would be helpful.

Thank you.
Dec 28 '06 #3
I'm guessing here on the solution as it sounds like the 32 bit millisecond
rollover. As for why the creation of a new timer - this should initialize
the timer to "0" and then it should be able to run for 49.7 days. When
windows hits 49.7 days (2^31-1) milliseconds, it simply rolls over to 0.
Windows 95 would actually become unstable at this point (if it hadn't
already done so from usage). As for your question, I don't have an answer
since for longer time periods I use the task manager to start an application
at a specific time and not application code.

Mike.

"igor" <jo********@yah oo.comwrote in message
news:11******** **************@ h40g2000cwb.goo glegroups.com.. .
Michael,
Thank you for your help. I have a couple of questions. Why is it
that resetting the timer variable to a new instance every month fixes
the issue? If the System.Timers.T imer class elapsed events fire when
the internal timer reaches a specific future time value, than wouldn't
any elapsed event set to fire after the 49.7 day point fail?

As I understand it, the internal timer you mention is the timer which
starts when the server is rebooted and increments until the 49.7 day
point is reached.

Thanks again

Michael D. Ober wrote:
>Why do I think the actual problem occurs at 49.7 days. This is a known
issue with 32 bit windows (2^31-1 milliseconds is about 49.7 days). It's
not that the timer service stops, it's that the internal timers wrap back
to
zero and the trigger doesn't occur anymore. The work around is to track
what day or month it is (numeric day of month or month of year is
sufficient) Here's an example workaround.

Module Module1
Public ReadOnly Interval As New System.TimeSpan (1, 0, 0)
Public t As New System.Timers.T imer(Interval.M illiseconds)
Public MonthNumber As Integer = Today.Month

Sub Main()
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End Sub

Private Sub t_Elapsed(ByVal sender As Object, ByVal e As
System.Timers. ElapsedEventArg s)
If MonthNumber <Today.Month Then
RemoveHandler t.Elapsed, AddressOf t_Elapsed
MonthNumber = Today.Month
t = New System.Timers.T imer(Interval.M illiseconds)
AddHandler t.Elapsed, AddressOf t_Elapsed
t.Start()
End If

' Proceess timer event
End Sub

End Module
Mike Ober.

"igor" <jo********@yah oo.comwrote in message
news:11******* *************** @a3g2000cwd.goo glegroups.com.. .
>I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.

I can convert the project to .Net Framework 2.0, but I am unsure
whether or not this will resolve the issue.

Any ideas would be helpful.

Thank you.

Dec 28 '06 #4
"Michael D. Ober" <obermd.@.alum. mit.edu.nospamw rote in
news:#Y******** ******@TK2MSFTN GP06.phx.gbl:
Why do I think the actual problem occurs at 49.7 days. This is a
known issue with 32 bit windows (2^31-1 milliseconds is about 49.7
days). It's not that the timer service stops, it's that the internal
timers wrap back to zero and the trigger doesn't occur anymore. The
work around is to track what day or month it is (numeric day of month
or month of year is sufficient) Here's an example workaround.
I recall seeing a KB article about this... do you happen to have any links
to any MS documentation?
I did find an article Joel on Software linked - Southern California's ATC
servers crashed after 49.7 days.

But I thought MS fixed this in a service pack?
Dec 28 '06 #5
"igor" <jo********@yah oo.comwrote in news:1167168930 .265904.288150
@a3g2000cwd.goo glegroups.com:
I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.

I can convert the project to .Net Framework 2.0, but I am unsure
whether or not this will resolve the issue.

Seems like there is a hotfix:

..NET 1.1
http://support.microsoft.com/kb/843561/en-us
Dec 28 '06 #6
igor wrote:
I have recently discovered that the system.Timers.T imer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event will stop
executing after 30 to 40 days. After learning this, I found the same
issue had been documented in the the System.Threadin g.Timer class as
well. This limits my options for having a timer based windows service
using the .net framework.
Only use the Timer to sidestep the Service's OnStart routine.
Within your "main processing" loop, use Threading.Sleep () instead, as in

Imports System.Threadin g

Private _bStopRequested as Boolean
Private _bStopped as Boolean

Sub OnStart()
tmrBoot.Start()
End Sub

Sub OnStop()
_bStopRequested = True
Do While Not _bStopped
Thread.Sleep(50 0)
Loop
End Sub

Sub tmrBoot_Timer()
tmrBoot.Stop()

Me.Run()
End Sub

Sub Run()
_Stopped = False
Do While Not bStopRequested
' Do the real work here

Thread.Sleep(10 00)
Loop
_Stopped = True
End Sub

HTH,
Phill W.
Jan 2 '07 #7
No links to documentation. Just my memory that this was a problem with
Windows 95 and early versions of NT prior to one of the NT4 service packs.
As far as I know, the server crash issue was fixed in Windows 98 and 2000.
However, the underlying problem itself - 32 bit timer counters rolling over
after 49.7 days will not be resolved until the transition to 64 bit
computing is complete. Then the rollover time will be measured in
centuries.

Mike.

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Michael D. Ober" <obermd.@.alum. mit.edu.nospamw rote in
news:#Y******** ******@TK2MSFTN GP06.phx.gbl:
>Why do I think the actual problem occurs at 49.7 days. This is a
known issue with 32 bit windows (2^31-1 milliseconds is about 49.7
days). It's not that the timer service stops, it's that the internal
timers wrap back to zero and the trigger doesn't occur anymore. The
work around is to track what day or month it is (numeric day of month
or month of year is sufficient) Here's an example workaround.

I recall seeing a KB article about this... do you happen to have any links
to any MS documentation?
I did find an article Joel on Software linked - Southern California's ATC
servers crashed after 49.7 days.

But I thought MS fixed this in a service pack?

Jan 2 '07 #8
"Michael D. Ober" <obermd.@.alum. mit.edu.nospamw rote in
news:e6******** ******@TK2MSFTN GP02.phx.gbl:
No links to documentation. Just my memory that this was a problem
with Windows 95 and early versions of NT prior to one of the NT4
service packs. As far as I know, the server crash issue was fixed in
Windows 98 and 2000. However, the underlying problem itself - 32 bit
timer counters rolling over after 49.7 days will not be resolved until
the transition to 64 bit computing is complete. Then the rollover
time will be measured in centuries.
Here's the SP: http://support.microsoft.com/kb/843561/en-us
Jan 2 '07 #9
You would think MS would have caught this during .NET 1.1 development since
the OS teams had already addressed and fixed problems with the same
underlying tickcount rollover.

Mike.

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Michael D. Ober" <obermd.@.alum. mit.edu.nospamw rote in
news:e6******** ******@TK2MSFTN GP02.phx.gbl:
>No links to documentation. Just my memory that this was a problem
with Windows 95 and early versions of NT prior to one of the NT4
service packs. As far as I know, the server crash issue was fixed in
Windows 98 and 2000. However, the underlying problem itself - 32 bit
timer counters rolling over after 49.7 days will not be resolved until
the transition to 64 bit computing is complete. Then the rollover
time will be measured in centuries.

Here's the SP: http://support.microsoft.com/kb/843561/en-us


Jan 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7460
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the...
3
5578
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan dueTime) is always set to 6 days, 23 hours, 59 minutes, .. Some weeks ?!?, the timer restarts immediately after its execution (and loop indefinitely)....
2
1711
by: Benjamin | last post by:
Hi, I am having a problem enabling a timer in my class. I have attached some sample pseudo code (see "Sample code illustrating issue") so you can see what I am talking about. Whats the issue? ================ I am unable to pause the timer when a timed event is thrown due to my event handling having a private scope. If I make the scope...
5
5077
by: Dhilip Kumar | last post by:
Hi all, I have developed a windows service using the windows service project template in VS.NET. I have used three controls in the service, a timer, performance counter and a message queue control. The service will "sleep" for 'n' seconds using the timer control and whenever the timer_elapsed event occurs, I use the performance counter...
8
2711
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a thread to access the database and then displays a modal dialog which allows the user to cancel the task, if it is taking longer than they want, and...
4
1680
by: Daniel | last post by:
Hey guys Here is what i want to do. I have made a multiplayer game that needs to when more than one player is ready start a countdown that the clients can see, so players can still join in this time frame and then after the time elapses the game starts. I am trying to do it lie this, my server controls all handling of the game logic,...
7
5973
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it seems recently connections just drop off because the timer stops firing. My question is if there is a timeout in the timer event that just shuts...
3
2459
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am trying to use the timer to make a login form show after a specified interval. However, if the interval is set to a value greater than 5000 nanosecond, then it does not respond. What could be the issue here? Thanks. private void frmMain_Load(object sender, EventArgs e) { this.timer = new Timer();
8
3359
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location on a network for files and then copies these files to another location (on the network) AND then updates a record in the database. The file copying...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.