I know that in Windows services you need to use System.Timers.Timer instead of System.Windows.Forms.Timer
- no problem there. In my OnStart method the code runs because I have debug code in there to write to a text file.
However, the same debug code won't write to a text when it's in the Elapsed event of the timer control.
Why??? The main program code is below - I don't think things can get much more simple than this.
I've searched on EE and all I can find is people solving the exact same issue by changing from System.Windows.Forms.Timer
to System.Timers.Timer ... I've already done that.
public partial class CheckWebUpload : ServiceBase
protected override void OnStart(string args)
// TODO: Add code here to start your service.
CheckUrl.Interval = 3000;
CheckUrl.Enabled = true;
protected override void OnStop()
// TODO: Add code here to perform any tear-down necessary to stop your service.
CheckUrl.Enabled = false;
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
StreamWriter SW = File.AppendText(@"c:\temp\temp.txt");