Hello,
I log all of my website/application errors to the event log. I have written
an service in vb.net that polls the event log every x hours and dumps all of
the "errors" to an email and sends it to necessary people and me.
----------------------------------------------------
Protected Overrides Sub OnStart(...)
Timer1.Interval = GetTimerIntervalInMilliSeconds()
Timer1.Enabled = True
End Sub
-----------------------------------
Private Sub Timer1_Elapsed(...)
Dim strContent As String
Dim aryEmailListTo As Array
aryEmailListTo = GetEmails()
strContent = MakeEmailBodyFromEventLogErrors()
SendEmail(aryEmailListTo, _EML_FROM, _EML_SUBJECT, strContent)
End Sub
------------------------------------------------------
EVERYTIME I restart the service (or reboot) it sends a TON of emails to me,
like timer1_elapsed is getting called a TON of times. Am I not setting the
Timer Interval in the right place? After it sends a TON of emails, it works
perfectly. If I set the interval to 2 hours, it works perfectly; i.e.,
every 2 hours I get 1 email with all of the relevant errors in the event
log, but the initial start sends me like 50 emails.
I made this about a year ago, and made it quickly with a "Make an NT service
in 5 minutes with vb.net" tutorial. I am finally debugging since I have to
make another new service and this would cripple the application if the
timer1.elapsed gets run 50 times on startup. I am pretty sure it didn't
error like this on my laptop when developing this.
thanks for any response,
-psb