System.timers.timer in windows service??

  • Thread starter Thread starter Kevin Yu
  • Start date Start date
K

Kevin Yu

hi all
I have a question for the timer in the windows service.
it seems that the code(e.g. sending an email message) within the timer
elapsed event handler won't run.
I have an eventlog writter within the handler too, the log is written
into the eventlog, but no email message is sent and there is not error
message given.

what's going on? do I have to create another process to call an external
exe?

Kevin
 
I typically stay away form the timers.timer and go with threading.timer in
services since mine tend to run a very long time.

If you're seeing log activity then the timer is probably fine but you want
to make sure that if you're using email (not sure which you're using) that
that object is setup properly. There are 5 or 6 different DLLs that support
the email in .NET (office cdo, cdonts, smtp... on and on) and they report
invalid email sends very poorly. Also since you'll typically be interoping
between .NET and these COM objects, you won't be able to drill through in
the debug window.
 
Drew

I move the code into the same function in the timer elapsed handler instead
of putting it in a separated class. now everything works fine. but the email
relay from the smtp server in our corporate network seems to be a bit slow,
I use SMTP component. It is an COM interop object. but it works.

thx for the response.

Kevin
 
Back
Top