473,714 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Service stopped working

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.File SystemWatcher) 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 ProperTimerInte rval() As Double
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"

Dim NextCheckTime As Date
If CInt(Time.Text. Substring(0, 2)) < CInt(Date.Now.H our) Then
NextCheckTime = Date.Parse(Date .Now.AddDays(1) .Date & " " &
Time.Text)
Else
NextCheckTime = Date.Parse(Date .Now.Date & " " & Time.Text)
End If
NextCheckTime = NextCheckTime.A ddHours(1)

Dim IntervalToRetur n As Double =
NextCheckTime.S ubtract(Date.No w).TotalMillise conds

If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("The daily timer is set to expire in " &
IntervalToRetur n & " milliseconds, which is " & IntervalToRetur n / 1000 / 60
/ 60 & " hours.", EventLogEntryTy pe.Information)
End If

Return IntervalToRetur n
End Function
Feb 20 '06 #1
2 2457
Did any of the responses posted in response to your original post on this
subject 5 days ago help?
"Trevor" <tsides @ intelligentsyst emsconsulting.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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.File SystemWatcher) 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 ProperTimerInte rval() As Double
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"

Dim NextCheckTime As Date
If CInt(Time.Text. Substring(0, 2)) < CInt(Date.Now.H our) Then
NextCheckTime = Date.Parse(Date .Now.AddDays(1) .Date & " " &
Time.Text)
Else
NextCheckTime = Date.Parse(Date .Now.Date & " " & Time.Text)
End If
NextCheckTime = NextCheckTime.A ddHours(1)

Dim IntervalToRetur n As Double =
NextCheckTime.S ubtract(Date.No w).TotalMillise conds

If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("The daily timer is set to expire in " &
IntervalToRetur n & " milliseconds, which is " & IntervalToRetur n / 1000 /
60 / 60 & " hours.", EventLogEntryTy pe.Information)
End If

Return IntervalToRetur n
End Function

Feb 21 '06 #2
I'm sorry; the original post/responses were not showing up in Outlook
Express, and I thouught the post never went out. I have done some digging
on groups.google.c om and found it all.

***I am now offering to pay someone who can fix this.***
***contact me: tsides AT intelligentsyst emsconsulting SPOT com***

The file is not transferred via FTP. My mistake. I went looking for FTP
logs, and then remembered: it is simply copied from one server to another,
both of which are on the same domain. The file size is almost always <100Kb
(2,000 CSV records @ approx. 50 bytes per), so it takes less than a second
between file creation and the completion of the write. Processing the file
finishes in a matter of seconds.

The other server is an Interactive Voice Response server. Each record in
the file represents an inbound phone call that the IVR system expects. As
of 2AM, the IVR server must wait until nobody is on the phone giving it
data. At the first opportunity when nobody is on the line, it stops
answering the calls, cuts the file, sends it to me, and waits for my
outbound file in return. While most calls are less than 10 minutes long,
and calls are not likely to be received at 2AM anyway, it never takes long
for the process to kick off. So, if the file hasn't arrived within the
hour, it isn't coming.

In 2.5 years, the file has failed to arrived only once.

The time interval is always updated (AutoReset = False). This way, the
inexperienced operators can change the expected arrival time in the config
file, but they don't have to know how to reboot the service to have it take
effect. Also, the timer expires at the interval, is shut off, and then is
turned back on after the new calculation.

I'll check the file sizes. Even though the inbound file is usually ready
for processing less than a second after it is recognized by
System.IO.FileS ystemWatcher, maybe the 20 second wait time is too short.
There'd be no harm in increasing that. However, I suspect the file on this
day was not unusual. Unfortunately, one of the things the process does is
delete files that are older than a month, to make sure the hard drive
doesn't fill up, so I can only back to the most recent one.

There is no "millisecon ds since startup" variable that is overloading.

I like the FileSystemWatch er because it enables the service to process a
file no matter when it comes. Also, this allows the operators to drop an
"empty" file out there and get an output file. If , for example, they ever
need to reboot the IVR server and start over with a new set of records
(expected calls). Also, it mamkes the whole thing somewhat foolproof if
someone changes the daily export time from the IVR server, but forgets to
change it on my end.

I suppose I could go to a Windows Scheduler process, but I'd have to
redesign the thing; I'd have to start checking the file system for the
existence of the inbound AND outbound files, I guess. Or I could write
"LastExecut ed" time to the database. I'd also have to move the
"UpdateFromConf iguration" process to the FileSystemWatch er, because ther are
other things in there that operators could change during the day, such as
the e-mail address to which errors and warnings are sent. (Regularly, not
all records in the inbound process can be loaded into the database, which is
not entirely unexepected, so they're written into an e-mail which goes out
as a warning for someone to verify.)

But I'd like to see if I can find out what's wrong with this code, first.
Again: ***I will pay someone to fix this***

More code, if it helps:
Private Sub DailyTimer_Elap sed(ByVal sender As System.Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles DailyTimer.Elap sed
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"

DailyTimer.Enab led = False

If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("The daily timer has expired: performing batch
functions and checking time of last execution.",
EventLogEntryTy pe.Information)
End If

Try
'clean the fieldlink output folder (defined by
OutputFolder.Te xt, which is populated from the config file automatically)
PurgeDirectory( FieldLinkOutput Folder.Text,
CInt(FieldLinkO utputDaysToKeep .Text))

'clean the out folder (defined by PathOut.Text, which is
populated from the config file automatically)
PurgeDirectory( PathOut.Text, CInt(OutDaysToK eep.Text))

'clean the in folder (defined by FileSystemWatch er1.Path, which
is populated from the config file sautomatically from PathIn)
PurgeDirectory( FileSystemWatch er1.Path, CInt(InDaysToKe ep.Text))
Catch ex As Exception
MyLog.WriteEntr y("The following problem occured while purging
directories: " & ex.Message, EventLogEntryTy pe.Warning)
End Try

Try
If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("Executing the SetExpectedMerc handisers
stored procedure to update the Visit table.", EventLogEntryTy pe.Information)
End If

Dim retVal As Int32 =
VisitManager.Se tExpectedMercha ndisers(Connect ionString.Text, Nothing,
DateTime.Now.Da te, "IVRImport" )
Catch ex As Exception
MyLog.WriteEntr y("The following problem occured while updating
Expected Merchandisers: " & ex.Message, EventLogEntryTy pe.Warning)
End Try

Try
If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("Executing the
ReleaseValidNon ReportedVisits stored procedure to update the Visit table.",
EventLogEntryTy pe.Information)
End If

VisitManager.Re leaseValidNonRe portedVisits(Co nnectionString. Text,
"AUTO", "IVRImport" )
Catch ex As Exception
MyLog.WriteEntr y("The following problem occured while releasing
valid non-reported visits: " & ex.Message, EventLogEntryTy pe.Warning)
End Try

'if the last executed date/time is not within the last 1.25 hours,
log an error and send an e-mail
If LastExecuted < Date.Now.AddHou rs(-1.25) Then
If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("Sending an e-mail because no Import file
was processed within the last 75 minutes.", EventLogEntryTy pe.Information)
End If

Dim ErrorMessage = String.Format(" As of {0:hh:mm} the IVR
Import/Export Launch service has still not detected a successful
Import/Export (which was expected to occur at about {1}). This may be
because the process failed (see previous Event Log entries) or because
{2}\{3} never arrived. Investigation into the problem is recommended.
Note: the IVR Import/Export will always process the expected file no matter
when it arrives.", DateTime.Now, Time.Text, FileSystemWatch er1.Path,
FileSystemWatch er1.Filter)
MyLog.WriteEntr y(ErrorMessage, EventLogEntryTy pe.Error)
If ToAddress.Text. ToLower <> "none" Then
SmtpMail.SmtpSe rver = "localhost"
SmtpMail.Send(F romAddress.Text , ToAddress.Text, "ERROR
NOTIFICATION: IVR Import did not occur", ErrorMessage)
End If
Else
If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("Determined that an Import file was
processed within the last 75 minutes; no e-mail was sent.",
EventLogEntryTy pe.Information)
End If
End If

UpdateFromConfi guration()
End Sub

Private Sub UpdateFromConfi guration()
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"

If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("Updating from configuration." ,
EventLogEntryTy pe.Information)
End If

CType(Me.FileSy stemWatcher1,
System.Componen tModel.ISupport Initialize).Beg inInit()
CType(Me.DailyT imer,
System.Componen tModel.ISupport Initialize).Beg inInit()

Try
'DSR - 8/14/2003
'Use .NET AppSettingsRead er instead of parsing XML
Dim AppSettings As AppSettingsRead er = New AppSettingsRead er

Me.FileSystemWa tcher1.Filter =
CType(AppSettin gs.GetValue("Fi leNameIn", GetType(System. String)), String)
Me.FileSystemWa tcher1.Path =
CType(AppSettin gs.GetValue("Pa thIn", GetType(System. String)), String)
Me.Time.Text = CType(AppSettin gs.GetValue("Ti me",
GetType(System. String)), String)
Me.PathOut.Text = CType(AppSettin gs.GetValue("Pa thOut",
GetType(System. String)), String)
Me.FileNameOut. Text = CType(AppSettin gs.GetValue("Fi leNameOut",
GetType(System. String)), String)
Me.OutDaysToKee p.Text =
CType(AppSettin gs.GetValue("Ou tDaysToKeep", GetType(System. String)), String)
Me.InDaysToKeep .Text =
CType(AppSettin gs.GetValue("In DaysToKeep", GetType(System. String)), String)
Me.FieldLinkOut putFolder.Text =
CType(AppSettin gs.GetValue("Fi eldLinkOutputFo lder", GetType(System. String)),
String)
Me.FieldLinkOut putDaysToKeep.T ext =
CType(AppSettin gs.GetValue("Fi eldLinkOutputDa ysToKeep",
GetType(System. String)), String)
Me.ToAddress.Te xt = CType(AppSettin gs.GetValue("To Address",
GetType(System. String)), String)
Me.FromAddress. Text = CType(AppSettin gs.GetValue("Fr omAddress",
GetType(System. String)), String)
Me.DefaultExten sion.Text =
CType(AppSettin gs.GetValue("Ma rketCoordinator DefaultExtensio n",
GetType(System. String)), String)
Me.ConnectionSt ring.Text =
CType(AppSettin gs.GetValue("Co nnectionString" , GetType(System. String)),
String)

Catch ex As Exception
MyLog.WriteEntr y("Unable to load configuration settings: " &
ex.Message, EventLogEntryTy pe.Warning)
End Try

CType(Me.FileSy stemWatcher1,
System.Componen tModel.ISupport Initialize).End Init()
CType(Me.DailyT imer,
System.Componen tModel.ISupport Initialize).End Init()

DailyTimer.Inte rval = ProperTimerInte rval()
DailyTimer.Enab led = True
End Sub

"Stephany Young" <noone@localhos t> wrote in message
news:u%******** *******@tk2msft ngp13.phx.gbl.. .
Did any of the responses posted in response to your original post on this
subject 5 days ago help?
"Trevor" <tsides @ intelligentsyst emsconsulting.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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.File SystemWatcher) 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 ProperTimerInte rval() As Double
Dim MyLog As New EventLog
MyLog.Source = "MyCompany"

Dim NextCheckTime As Date
If CInt(Time.Text. Substring(0, 2)) < CInt(Date.Now.H our) Then
NextCheckTime = Date.Parse(Date .Now.AddDays(1) .Date & " " &
Time.Text)
Else
NextCheckTime = Date.Parse(Date .Now.Date & " " & Time.Text)
End If
NextCheckTime = NextCheckTime.A ddHours(1)

Dim IntervalToRetur n As Double =
NextCheckTime.S ubtract(Date.No w).TotalMillise conds

If Debug.Text.ToLo wer = "true" Then
MyLog.WriteEntr y("The daily timer is set to expire in " &
IntervalToRetur n & " milliseconds, which is " & IntervalToRetur n / 1000 /
60 / 60 & " hours.", EventLogEntryTy pe.Information)
End If

Return IntervalToRetur n
End Function


Feb 21 '06 #3

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

Similar topics

1
5687
by: Artur Kowalski | last post by:
I have a NotifyIcon in my Windows Service project and I am trying to add a ContextMenu to this NotifyIcon or use some of the mouse events. Everything isn't working. I think so base class of the service System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or timer messages. Any Idea? Thanks,
7
712
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: service 1 - my service watches service 2 - windows service service 2 is stopped - service 1 starts service 2
9
7269
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service stopping. Please advise how to stop the service. Thanks, SP
0
3936
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server - Select from two specific services - Check the status of the server
6
3804
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop() ServiceController.WaitForStatus(ServiceControllerStatus.Stopped) ServiceController.start() but doesn´t works. It seems waitforstatus instruction is the last
6
8110
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class functions __init__, SvcStop, and SvcDoRun (which contains my server code). After registering the service, I am able to start it with no problems. However, it never stops correctly (net stop returns "service could not be stopped") and service is left...
12
14532
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
3
1410
by: Terry Olsen | last post by:
I have a windows service that has been running fine for almost 6 months. Last week, it just stopped working. It is still in the task list and still shows "started" in the service manager. There are no exceptions thrown, it just seems to have fell asleep. The service runs in a loop that checks about 80 servers on a daily basis to see what the status of the previous nights backup job is. It downloads the zipped log files from each...
7
3213
by: Ashish Khandelwal | last post by:
I have a Windows Service in C# talking to a serial port and using Remoting. It also uses several COM objects. On server the service will occassionally hang somewhere - the service still shows on a Task Manager list. In Services it says it is still running. However there is no way to stop it other than by rebooting the whole computer. No exception (including non-CLS) is ever generated. I added a separate System.Timers.Timer
0
8707
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6634
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3158
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
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.