Window Services
-
Hi All, I have build a window service with timer in it and i want to enter log after every 5 minutes,so I have written code in Timer_tick function , but It's not working ,Can I do that way , Or there is another way of doing it. Thanks & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
-
Hi All, I have build a window service with timer in it and i want to enter log after every 5 minutes,so I have written code in Timer_tick function , but It's not working ,Can I do that way , Or there is another way of doing it. Thanks & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
send me the code ....I will ty to rectify it.
-
send me the code ....I will ty to rectify it.
Hi Sonia, Namespace AlertService { public partial class AlertService : ServiceBase { public AlertService() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: Add code here to start your service. timer1.Enabled = true; } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. timer1.Enabled = false ; } protected override void OnPause() { timer1.Enabled = false; //base.OnPause(); } protected override void OnContinue() { timer1.Enabled = true; //base.OnContinue(); } private void timer1_Tick(object sender, EventArgs e) { eventLog1.WriteEntry("Hai it's now " + DateTime.Now.ToString()); } } } This is what i have coded , Installation is working well with custom Event log , Start , Stop Pause , Continue is Logged but Only the Timer is not working Regards & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
-
Hi Sonia, Namespace AlertService { public partial class AlertService : ServiceBase { public AlertService() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: Add code here to start your service. timer1.Enabled = true; } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. timer1.Enabled = false ; } protected override void OnPause() { timer1.Enabled = false; //base.OnPause(); } protected override void OnContinue() { timer1.Enabled = true; //base.OnContinue(); } private void timer1_Tick(object sender, EventArgs e) { eventLog1.WriteEntry("Hai it's now " + DateTime.Now.ToString()); } } } This is what i have coded , Installation is working well with custom Event log , Start , Stop Pause , Continue is Logged but Only the Timer is not working Regards & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
You are using Window based Timer. User System.Threading.Timer instead...
M Aamir Maniar aamirOnline.com
-
You are using Window based Timer. User System.Threading.Timer instead...
M Aamir Maniar aamirOnline.com
Hi A I will try this and let you know Regards & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
-
Hi Sonia, Namespace AlertService { public partial class AlertService : ServiceBase { public AlertService() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: Add code here to start your service. timer1.Enabled = true; } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. timer1.Enabled = false ; } protected override void OnPause() { timer1.Enabled = false; //base.OnPause(); } protected override void OnContinue() { timer1.Enabled = true; //base.OnContinue(); } private void timer1_Tick(object sender, EventArgs e) { eventLog1.WriteEntry("Hai it's now " + DateTime.Now.ToString()); } } } This is what i have coded , Installation is working well with custom Event log , Start , Stop Pause , Continue is Logged but Only the Timer is not working Regards & Wishes Navneet Hegde Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
Next time, use the C# forum if you're working in C# code.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007