Click here to Skip to main content
15,886,049 members
Home / Discussions / C#
   

C#

 
GeneralRe: SQL Table Pin
dan!sh 15-Jul-09 7:03
professional dan!sh 15-Jul-09 7:03 
GeneralRe: SQL Table Pin
kibromg15-Jul-09 7:15
kibromg15-Jul-09 7:15 
GeneralRe: SQL Table [modified] Pin
musefan15-Jul-09 8:08
musefan15-Jul-09 8:08 
AnswerRe: SQL Table Pin
Luc Pattyn15-Jul-09 8:24
sitebuilderLuc Pattyn15-Jul-09 8:24 
GeneralRe: SQL Table Pin
musefan15-Jul-09 21:53
musefan15-Jul-09 21:53 
AnswerRe: SQL Table Pin
Pete O'Hanlon15-Jul-09 10:02
mvePete O'Hanlon15-Jul-09 10:02 
GeneralRe: SQL Table Pin
Not Active15-Jul-09 10:10
mentorNot Active15-Jul-09 10:10 
QuestionHow to implement a timer in Windows Service correctly? Pin
astv15-Jul-09 5:16
astv15-Jul-09 5:16 
In this windows service, I have a log configured to record the Windows Service Start and Stop state and the process triggered by a timer. The process is sending an email notification once a day.

Currently, the Windows Service Start and Stop state is recoding successfully in the log. The email notification process triggered by the timer however is not doing anything. Any help is much appreciated.

See my script below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Timers;

namespace IRISEmailNotifier
{
public partial class IRISEmailNotifier : ServiceBase
{
public IRISEmailNotifier()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
try
{
LogEntry le = new LogEntry("Start - " + DateTime.Now.ToString() + "\n");

this.timer1.Interval = 10000;
this.timer1.Enabled = true;
this.timer1.Tick += new EventHandler(timer1_Tick);
}
catch (Exception ex)
{
LogEntry le = new LogEntry(ex.ToString());
}
}

void timer1_Tick(object sender, EventArgs e)
{
try
{
LogEntry le = new LogEntry("Send Email - " + DateTime.Now.ToString() + "\n");
}
catch (Exception ex)
{
LogEntry le = new LogEntry(ex.ToString());
}
}

protected override void OnStop()
{
try
{
LogEntry le = new LogEntry("Stop - " + DateTime.Now.ToString() + "\n");

this.timer1.Enabled = false;
}
catch (Exception ex)
{
LogEntry le = new LogEntry(ex.ToString());
}
}

private void SendEmailNotification()
{
try
{
LogEntry le = new LogEntry("Send Email - " + DateTime.Now.ToString() + "\n");
}
catch (Exception ex)
{
LogEntry le = new LogEntry(ex.ToString());
}
}
}
}

Thanks, Steve C.

Steve C.
kstv@netzero.net

AnswerRe: How to implement a timer in Windows Service correctly? Pin
DoctorMick15-Jul-09 6:04
DoctorMick15-Jul-09 6:04 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
astv15-Jul-09 6:13
astv15-Jul-09 6:13 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
DoctorMick15-Jul-09 6:26
DoctorMick15-Jul-09 6:26 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
astv15-Jul-09 10:41
astv15-Jul-09 10:41 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
Luc Pattyn15-Jul-09 6:26
sitebuilderLuc Pattyn15-Jul-09 6:26 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
astv15-Jul-09 10:43
astv15-Jul-09 10:43 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
Paladin200015-Jul-09 6:27
Paladin200015-Jul-09 6:27 
GeneralRe: How to implement a timer in Windows Service correctly? Pin
astv15-Jul-09 10:45
astv15-Jul-09 10:45 
AnswerRe: How to implement a timer in Windows Service correctly? Pin
dan!sh 15-Jul-09 6:28
professional dan!sh 15-Jul-09 6:28 
QuestionOutlook newitem event issue [modified] Pin
ghoster00715-Jul-09 5:06
ghoster00715-Jul-09 5:06 
AnswerRe: Outlook newitem event issue Pin
Luc Pattyn15-Jul-09 6:19
sitebuilderLuc Pattyn15-Jul-09 6:19 
GeneralRe: Outlook newitem event issue Pin
ghoster00715-Jul-09 7:00
ghoster00715-Jul-09 7:00 
GeneralRe: Outlook newitem event issue Pin
Luc Pattyn15-Jul-09 7:08
sitebuilderLuc Pattyn15-Jul-09 7:08 
GeneralRe: Outlook newitem event issue Pin
ghoster00715-Jul-09 9:08
ghoster00715-Jul-09 9:08 
QuestionUse of GC.SuppressFinalize in ref counted objects Pin
molesworth15-Jul-09 4:55
molesworth15-Jul-09 4:55 
QuestionCreating four dimensional control Pin
gwithey15-Jul-09 4:32
gwithey15-Jul-09 4:32 
AnswerRe: Creating four dimensional control Pin
OriginalGriff15-Jul-09 4:49
mveOriginalGriff15-Jul-09 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.