TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Erik Petersen
NA
6
0
System.Threading timer problem for beginner (Windows service, sending e-mails)
Jun 7 2006 7:05 PM
I'm trying to do a windows service for the first time, and I would like it to send an e-mail with a specific interval. The problem is that it sends all the e-mails when I turn the service off, I would like it to send e-mails when it is running.
I get no errors in my code and would think the problem lies in the code below. Can anyone help me or suggest a better solution?
I am testing it on my computer with XP Professional and using the virtual SMTP on IIS, but it is going to be installed on a 2003 Server later. Does this make any difference?
public
partial
class
mailTimer
:
ServiceBase
{
private
mailJob
job;
private
Timer
stateTimer;
private
TimerCallback
timerDelegate;
public
mailTimer(){
ServiceName =
"Mail Service"
;
CanStop =
true
;
CanPauseAndContinue =
false
;
AutoLog =
true
;
}
protected
override
void
OnStart(
string
[] args){
job =
new
mailJob
();
timerDelegate =
new
TimerCallback
(job.doSomething);
stateTimer =
new
Timer
(timerDelegate,
null
, 30000, 30000);
}
protected
override
void
OnStop(){
stateTimer.Dispose();
}
}
Thanks for any help!
Reply
Answers (
1
)
Synchronizing two different objects
Opening Microsoft Office files in a multithreaded environment