473,387 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Timer in a Windows Service not firing?

Hi all.
I have a service I am writing. The last step of the onLoad event is to
enable a timer, however this timer never seems to fire. I have added a line
of code after the timer enable line to write the status to the event log,
and this definitely says the enabled property is true... but I have also put
an event-log-writing line as the first step in the timer firing event, and
this never gets logged.

Is there something weird I am missing to do with services? Err...
James.
Sep 15 '06 #1
3 3612
james wrote:
Hi all.
I have a service I am writing. The last step of the onLoad event is to
enable a timer, however this timer never seems to fire. I have added a line
of code after the timer enable line to write the status to the event log,
and this definitely says the enabled property is true... but I have also put
an event-log-writing line as the first step in the timer firing event, and
this never gets logged.

Is there something weird I am missing to do with services? Err...
What kind of timer did you use? You should not use the
System.Windows.Forms.Timer as that will not work in a service. You
should use a System.Timers.Timer or a System.Threading.Timer instead.

Sep 15 '06 #2
What kind of timer? And which onLoad event are you refering to?
If you're trying to put UI stuff in your service, then please rethink your
design.

/claes

"james" <ja***@com.comwrote in message
news:45**********************@news.zen.co.uk...
Hi all.
I have a service I am writing. The last step of the onLoad event is to
enable a timer, however this timer never seems to fire. I have added a
line of code after the timer enable line to write the status to the event
log, and this definitely says the enabled property is true... but I have
also put an event-log-writing line as the first step in the timer firing
event, and this never gets logged.

Is there something weird I am missing to do with services? Err...
James.

Sep 15 '06 #3

"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:Oh*************@TK2MSFTNGP05.phx.gbl...
What kind of timer? And which onLoad event are you refering to?
If you're trying to put UI stuff in your service, then please rethink your
design.

A forms timer - I think Chris has hit on the answer as well. Rather than
dragging the timer into the service "designer", I should just create a
system timer in code instead. My service definitely doesn't have or need any
UI stuff, I just forgot that the timer in the toolbox isn't the same thing!
Thanks guys.
Sep 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steve Jorgensen | last post by:
I know quite well that this question falls into the category of "why does Access misbehave when I do unexpected things to its objects?", but I thought I'd ask anyway, and see if anyone knows. ...
2
by: andrewcw | last post by:
I am trying to do a windows service with C#. I am using as a base the VB.NET article in VS, but I thing the WITHEVENTS timer notation is a delegate. Can anyone provide sample code & anh hints. ...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
2
by: linesh.gajera | last post by:
Hi Guys, I am creating a Windows service that call a routine at given interval. Once routine is complete, windows service should wait for 5 minutes and then call the routine again. I was using...
4
by: Brian P | last post by:
I have a service that is driven by a timer that fires every 5 seconds. For the most part, it works fine. But every once in a while the timer fires twice. In the log I can see that when it fires...
2
by: jajalc | last post by:
Hi all, WE have a windows service using .net and which uses a System.Timers.Timer..all the of code works fine..... but after a extended period of time the timer just stops firing the elasped...
9
by: archana | last post by:
Hi all, I want to know about interval of timer. I am using timer in windows service.I head somewhere that when i set interval property of timer while setting interval, restart time of Pc is...
19
by: adi | last post by:
Hi I need the following: at particular times of day, I want to make some processing. System.Windoes.Timer doesn't help much, because it exposes the Interval property. Instead, I need to tell...
7
by: Daniele Piccinini | last post by:
Hallo, I've writed a C# windows service in VS 2003. This service use a System.Timers.Timer to periodically call some functions of a web service. ( Some of this functions required minutes to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.