Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2006, 04:54 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default System.Threading timer problem for beginner (Windo

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!



 
Old June 8th, 2006, 08:03 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

RESOLVED!

Have now tried it on the Server 2003 and it works fine. Do not know why it does not work on my machine, but the important thing is that it works on the server.

/Erik






Similar Threads
Thread Thread Starter Forum Replies Last Post
I signed a .cab file and its still bloked by windo sugar VBScript 0 April 28th, 2006 07:33 PM
Timer Problem gaurav_jain2403 ASP.NET 1.x and 2.0 Application Design 11 February 18th, 2006 09:37 PM
Understanding System.Threading.ReaderWriterLock AgentSmith General .NET 1 September 8th, 2005 02:38 PM
Windows Form Threading Problem nugie73 VB.NET 0 August 25th, 2004 06:12 AM
ATL Com Dll :problem in threading eternalme Visual C++ 0 April 20th, 2004 12:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.