473,394 Members | 1,671 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,394 software developers and data experts.

Timer not working in .net

Hi all

I am having application which is using server based timer that is timer

from namespace system.timer.

I am having windows service which i want to run after every 1 hour and
after every one hour i am sending mail.

In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am calling function of sending mail.

But even if i set interval as1 hours my code is sometime running
continuously means sending mail after 1 min only instead of after 1
hour which is increasing my mail box size.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Am i doing something wrong?

thanks in advance,

Apr 10 '06 #1
4 2314
Can you post some code. I prefer the System.Threading.Timer timer myself.

--
William Stacey [MVP]

"archana" <tr**************@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
| Hi all
|
| I am having application which is using server based timer that is timer
|
| from namespace system.timer.
|
| I am having windows service which i want to run after every 1 hour and
| after every one hour i am sending mail.
|
| In service.cs class i am creating one worker thread and in thread
| procedure i am enabling one timer after thread procedure is completed
| and in timer's elapsed event i am calling function of sending mail.
|
| But even if i set interval as1 hours my code is sometime running
| continuously means sending mail after 1 min only instead of after 1
| hour which is increasing my mail box size.
|
| Can some one tell me why thisis happening. Or can't i start timer in
| thread procedure at the end of thread procedure.
|
| Am i doing something wrong?
|
| thanks in advance,
|
Apr 10 '06 #2
If this thing needs to "Rip Van Winkle" for a full hour before it ever wakes
up and does something, I think you'd be better served by just writing it as a
console app and having Task Scheduler call it once an hour. No need to have
the overhead of a service just to have it wake up and do something once per
hour.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"archana" wrote:
Hi all

I am having application which is using server based timer that is timer

from namespace system.timer.

I am having windows service which i want to run after every 1 hour and
after every one hour i am sending mail.

In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am calling function of sending mail.

But even if i set interval as1 hours my code is sometime running
continuously means sending mail after 1 min only instead of after 1
hour which is increasing my mail box size.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Am i doing something wrong?

thanks in advance,

Apr 10 '06 #3
Hi,

thanks to ur reply.

but i want to know reason behind this as currently i am using timer in
all my application.

So changing it to console application will create some overheads for
me.

So please tell me why this is happening. I am not doing any heavy
processing which will require more than hour.

If u have any idea please help me.

thanks in advance.
Peter wrote:
If this thing needs to "Rip Van Winkle" for a full hour before it ever wakes
up and does something, I think you'd be better served by just writing it as a
console app and having Task Scheduler call it once an hour. No need to have
the overhead of a service just to have it wake up and do something once per
hour.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"archana" wrote:
Hi all

I am having application which is using server based timer that is timer

from namespace system.timer.

I am having windows service which i want to run after every 1 hour and
after every one hour i am sending mail.

In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am calling function of sending mail.

But even if i set interval as1 hours my code is sometime running
continuously means sending mail after 1 min only instead of after 1
hour which is increasing my mail box size.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Am i doing something wrong?

thanks in advance,


Apr 11 '06 #4
Archana,
converting your app to a console app that gets run on a scheduled basis by
Task Scheduler should reduce, not increase the overhead, since a timer would
no longer be necessary. Your app would simply do its thing in its Main( )
method each time it is run and then quit. No service overhead, and only a
minimal memory footprint for a short period of time whenever it is run.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"archana" wrote:
Hi,

thanks to ur reply.

but i want to know reason behind this as currently i am using timer in
all my application.

So changing it to console application will create some overheads for
me.

So please tell me why this is happening. I am not doing any heavy
processing which will require more than hour.

If u have any idea please help me.

thanks in advance.
Peter wrote:
If this thing needs to "Rip Van Winkle" for a full hour before it ever wakes
up and does something, I think you'd be better served by just writing it as a
console app and having Task Scheduler call it once an hour. No need to have
the overhead of a service just to have it wake up and do something once per
hour.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"archana" wrote:
Hi all

I am having application which is using server based timer that is timer

from namespace system.timer.

I am having windows service which i want to run after every 1 hour and
after every one hour i am sending mail.

In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am calling function of sending mail.

But even if i set interval as1 hours my code is sometime running
continuously means sending mail after 1 min only instead of after 1
hour which is increasing my mail box size.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Am i doing something wrong?

thanks in advance,


Apr 11 '06 #5

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
7
by: J. Hill | last post by:
I have a Windows Service with a timer but the .Tick event is not being fired/called. Don't know what code to include...I enabled and started the timer...I have the exact same code in a Windows...
2
by: hnkien | last post by:
Hi, I am writing a windows service with threading.timer for 10 seconds but it didn't work. Here are my code: namespace SchedulerService { public class ScheduleService :...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
3
by: sherifffruitfly | last post by:
I admit it - I don't have the foggiest notion how to use the timer class(es) in c# - i've looked at tutorials, and it's still completely unintutive to me. Anyone nice enough to get me started on...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
4
by: Max | last post by:
This may be an elementary question but it's something I have not encountered in about 10 years writing code in VB 5 / 6 I have a timer that using the API checks if there has been a change to one...
4
by: sophistiKate | last post by:
I am working with an Access 2003 database. Since adding a timer event to check for idle time to a form, a custom toolbar button that creates a snapshot has stopped working properly. Until the first...
11
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.