Re: Windows Service stopped working
- From: "Stephany Young" <noone@localhost>
- Date: Tue, 21 Feb 2006 21:02:52 +1300
Did any of the responses posted in response to your original post on this
subject 5 days ago help?
"Trevor" <tsides @ intelligentsystemsconsulting.com> wrote in message
news:%23k9NuYlNGHA.3732@xxxxxxxxxxxxxxxxxxxxxxx
Argh! This problem is driving me nuts! Can you help?
In November of 2003, I installed a web service on Windows Server 2003
built in VB.NET for v1.1.4322 of the framework. It contains a timer
(System.Timers.Timer) which has an interval of 24 hours. Actually, it
reads a time like 2AM out of the config file, and calculates the time
between the start of the service to 2AM, and sets the timer. When the
timer expires, it re-reads the configuration file (in case it has changed)
and re-sets the timer (which usually ends up being 24 hours).
When the timer expires, it compares the current system time against a
global variable (Private LastExecuted As Date). LastExecuted is set as
the current time when a File Watcher (System.IO.FileSystemWatcher) is
tickled. So, when the timer expires at 2AM, it makes a database update,
then checks to see that LastExecuted is not more than an hour ago,
otherwise it sends an e-mail (the file we expected to receive today didn't
arrive).
After running continuously since November 2003, the timer suddenly started
setting itself to sub-second intervals in May, 2005. When people came to
work in the morning to 5,000+ e-mail messages, I got the call. I rebooted
the service, and all was fine until Dec. 2005, when it happened again.
Now, in Feb. 2006, it has happened again, and the only way to stop the
sub-second time intervals was to reboot the whole server. Interstingly,
even though the timer expired several times per second and sending an
e-mail every time, it wasn't re-reading the configuration file (the next
subroutine call after sending the e-mails) and recognizing changes to the
values therein. A week later, though, the timer now has some unknown
interval (because it's not expiring at all, or, the elapsed logic -
database update, e-mails and configuration file read - are not happening).
This server used to be rebooted on a daily basis, but that stopped
sometime in 2004 or 2005. I don't know if that's a clue to the problem.
I use the Event Log a lot. Should I be releasing the memory reserved by
the MyLog variable? Otherwise, I have no idea what might be wrong with
the code. Please help!
In case this helps - the code which sets the interval of the timer:
Private Function ProperTimerInterval() As Double
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"
Dim NextCheckTime As Date
If CInt(Time.Text.Substring(0, 2)) < CInt(Date.Now.Hour) Then
NextCheckTime = Date.Parse(Date.Now.AddDays(1).Date & " " &
Time.Text)
Else
NextCheckTime = Date.Parse(Date.Now.Date & " " & Time.Text)
End If
NextCheckTime = NextCheckTime.AddHours(1)
Dim IntervalToReturn As Double =
NextCheckTime.Subtract(Date.Now).TotalMilliseconds
If Debug.Text.ToLower = "true" Then
MyLog.WriteEntry("The daily timer is set to expire in " &
IntervalToReturn & " milliseconds, which is " & IntervalToReturn / 1000 /
60 / 60 & " hours.", EventLogEntryType.Information)
End If
Return IntervalToReturn
End Function
.
- Prev by Date: Re: sub Main
- Next by Date: Re: sub Main
- Previous by thread: Thx
- Next by thread: Which Database type to use?
- Index(es):
Relevant Pages
|