473,661 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2335
Can you post some code. I prefer the System.Threadin g.Timer timer myself.

--
William Stacey [MVP]

"archana" <tr************ **@yahoo.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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
7477
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 it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
7
33570
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 form and it works fine, but in the service: nothing. .... this.components = new System.ComponentModel.Container(); this.tmrTimer = new System.Windows.Forms.Timer(this.components); // // tmrTimer //
2
8459
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 : System.ServiceProcess.ServiceBase { private System.ComponentModel.IContainer components; protected System.Threading.Timer tmrThreadingTimer;
4
11110
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 the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a time to close property which is checked every time the Elapsed event fires. The problem I have...
3
1326
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 the following problem would be my favorite person in the world! A file is made available on a network drive sometime after noon, and I want to copy it. I want the application to wait until 12 noon, check for the file, if it's there, copy it, if...
8
6855
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 never used this timer. I used the documentation from Microsoft as a guide, but I cannot get this timer to work. Protected Overrides Sub OnStart(ByVal args() As String) Dim myTimer As New TimerState()
4
7031
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 of several watched directories in the file system, if there has been a change a rather long running process is started. The long running process loops through all files comparing the last modified attributes on each to those in the database if...
4
2373
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 time the timer event procedure is run, the button works fine, but after that, it produces an error "The Object Type argument for the action or method is blank or invalid." The button runs a macro which runs the action "OutputTo" with the following...
11
2591
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 library as I thought this would be a good start!!!) but nothing happens :- Imports System.Timers
3
3864
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 Thread)? In some of the timers I update some UI controls e.g statusbar.labels and I
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.