Click here to Skip to main content
15,891,905 members
Home / Discussions / C#
   

C#

 
Questioncomputer share rights Pin
caiena15-Jul-09 6:54
caiena15-Jul-09 6:54 
AnswerRe: computer share rights Pin
dan!sh 15-Jul-09 7:18
professional dan!sh 15-Jul-09 7:18 
GeneralRe: computer share rights Pin
caiena15-Jul-09 8:44
caiena15-Jul-09 8:44 
QuestionSQL Table Pin
kibromg15-Jul-09 6:12
kibromg15-Jul-09 6:12 
AnswerRe: SQL Table Pin
dan!sh 15-Jul-09 6:19
professional dan!sh 15-Jul-09 6:19 
GeneralRe: SQL Table Pin
kibromg15-Jul-09 6:53
kibromg15-Jul-09 6:53 
GeneralRe: SQL Table Pin
kibromg15-Jul-09 7:01
kibromg15-Jul-09 7:01 
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 

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.