473,763 Members | 2,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does timer interval gets stored anywhere in system or in registry.

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 consider.

My question is if i am using timer in my windows service, is there any
place where interval related information like interval set used by my
application is stored.

My problem is my timer start behaving erractically after 49.7 days. So
instead of restarting PC i reinstall service and problem gets solved.
So i want to know where in system timer related information is stored.

If anyone can shed some light on it then it will be really benefical
for me.

thanks in advance.

Oct 4 '06 #1
9 2645
Hi Archana,

A possible workaround might be to dispose the Timer instance every day
or so and create a new instance to work with.

archana wrote:
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 consider.

My question is if i am using timer in my windows service, is there any
place where interval related information like interval set used by my
application is stored.

My problem is my timer start behaving erractically after 49.7 days. So
instead of restarting PC i reinstall service and problem gets solved.
So i want to know where in system timer related information is stored.

If anyone can shed some light on it then it will be really benefical
for me.

thanks in advance.

--
Ward Bekker

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Oct 4 '06 #2
Hi,

thanks for your reply.

But i can't dispose timer object every day as i want my application to
be continusously running.

Can you tell me any other solution.

any help will be truely appreciated.

thanks in advance.

Oct 4 '06 #3
If all the timer is doing is firing an event on a regular basic, why can't
you dispose it, and create a new instance of the timer which you will link
to the same event again:

Not sure what mechanism you'd use to call it.
-Maybe another timer - possibly then you'd need to re-start the second timer
as well...?
-Maybe you could count the number of times the timer's event fires and call
the method below every 1000 times of whatever seems sensible.

private void ReMakeTimer() // Call this once a day, or whenever.
{
myTimer = new Timer();
myTimer.Enabled = true;
myTimer.Interva l = 2000;// of whatever your required interval is
myTimer.Tick +=new EventHandler(my Timer_Tick);//of whatever the method the
timer calls is called...
}

"archana" <tr************ **@yahoo.comwro te in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
Hi,

thanks for your reply.

But i can't dispose timer object every day as i want my application to
be continusously running.

Can you tell me any other solution.

any help will be truely appreciated.

thanks in advance.

Oct 4 '06 #4
Hi,

I'm guessing the tick count resets to 0 after 49 days or so in which case
your timer might fire at new times. It might that this is easily solved
by resetting the interval regularly, or dispose and recreate the timer
every now and then.

Note also that you probably should use System.Threadin g.Timer if you are
using System.Timers.T imer as the latter have been reported to be somewhat
unstable for windows services.

On Wed, 04 Oct 2006 12:02:22 +0200, archana <tr************ **@yahoo.com>
wrote:
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 consider.

My question is if i am using timer in my windows service, is there any
place where interval related information like interval set used by my
application is stored.

My problem is my timer start behaving erractically after 49.7 days. So
instead of restarting PC i reinstall service and problem gets solved.
So i want to know where in system timer related information is stored.

If anyone can shed some light on it then it will be really benefical
for me.

thanks in advance.


--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 4 '06 #5
Hi all,

thanks for reply.

one more question is if i restarted my windows service still timer is
behaving erractically.

Actually after restart my application should start workin properly.

To start application to work properly i have to restart my pc.

can someone tell me reason behind this.

Any help will be truely appreciated.

thanks in advance.

Oct 4 '06 #6
What exactly do you mean by behaving erratically?
What is the expected timer interval, and what is actually happening?

Could there be somthing else in your program that is firing and maybe
holding up processing, hence causing your timer event to run 'late'?
As it happens after a while, could your program have a memory leak or
somthing?

Strange that it still happens after re-starting the service! Does the
program rely on anything else outside its 'domain' that could be causing a
problem?

"archana" <tr************ **@yahoo.comwro te in message
news:11******** **************@ c28g2000cwb.goo glegroups.com.. .
Hi all,

thanks for reply.

one more question is if i restarted my windows service still timer is
behaving erractically.

Actually after restart my application should start workin properly.

To start application to work properly i have to restart my pc.

can someone tell me reason behind this.

Any help will be truely appreciated.

thanks in advance.

Oct 4 '06 #7
Hi,

Let me elaborate my point.

I have one function which i am executing on elapsed event of timer.
I am expecting this function to be executed once a day so i set
interval to execute it once a day. My application is working properly
say for nearly 30 days.

Suddenly instead of firing elasped event once a day timer getting fired
per mins sometime per seconds also.

I am strange why this is happening. Can you tell me reason behind
this.

Any help will be truely appreciated.
Thanks in advance.

ChrisM wrote:
What exactly do you mean by behaving erratically?
What is the expected timer interval, and what is actually happening?

Could there be somthing else in your program that is firing and maybe
holding up processing, hence causing your timer event to run 'late'?
As it happens after a while, could your program have a memory leak or
somthing?

Strange that it still happens after re-starting the service! Does the
program rely on anything else outside its 'domain' that could be causing a
problem?

"archana" <tr************ **@yahoo.comwro te in message
news:11******** **************@ c28g2000cwb.goo glegroups.com.. .
Hi all,

thanks for reply.

one more question is if i restarted my windows service still timer is
behaving erractically.

Actually after restart my application should start workin properly.

To start application to work properly i have to restart my pc.

can someone tell me reason behind this.

Any help will be truely appreciated.

thanks in advance.
Oct 5 '06 #8

Instead of a Timer (dragged onto the form) try a "coded" timer.

Sorry, I only have some old old vb.net code for this one currently.
Outside of "addhandler " ( += new EventHandler) it should be easy enough to
translate)
Private m_doTheWorkTime r As Timer

private sub RegisterTimer()

Dim dueTime As Long

Dim period As Long

' DUE TIME looks like it is the DELAY time .. from the time the service
starts,

' Until this specfic TIMER kicks in. So a Delay Time of 20000

' Will DELAY this timer shooting off until 20 seconds (20000 ms) after the
service starts

dueTime = 20000

period = 5000

' the magic bullet, notice the part after "AddressOf" , which is the method

Dim timerHandler = New TimerCallback(A ddressOf BeepClass.GoBee p)

m_doTheWorkTime r = New Timer(timerHand ler , Me, dueTime, period)

end sub

''Above is the Code Behind of the Windows Service



Public Class BeepClass

Public Shared Sub GoBeep(ByVal state As Object)'' this uses a built in
delegate, with "state as Object" as the generic argument list

Beep()

End Sub

End Class
Also, you may want to read this post (the result authored by me)
http://groups.google.com/groups/sear...r+&qt_s=Search

"archana" <tr************ **@yahoo.comwro te in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
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 consider.

My question is if i am using timer in my windows service, is there any
place where interval related information like interval set used by my
application is stored.

My problem is my timer start behaving erractically after 49.7 days. So
instead of restarting PC i reinstall service and problem gets solved.
So i want to know where in system timer related information is stored.

If anyone can shed some light on it then it will be really benefical
for me.

thanks in advance.

Oct 5 '06 #9
Use a runonce timer and reset it every time in the callback. This also
gives you change to correct drift or other errors:

private void button24_Click( object sender, EventArgs e)
{
Console.WriteLi ne("Running a job every 5 seconds.");
System.Threadin g.Timer timer = null;
timer = new System.Threadin g.Timer(
delegate(object state)
{
timer.Change(50 00, -1);
Console.WriteLi ne("Job ran at: {0}", DateTime.Now);
}, null, 5000, -1);
}

I did not run this for 40 days, but should work. You could also just create
a new timer.

--
William Stacey [C# MVP]

"archana" <tr************ **@yahoo.comwro te in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
| Hi,
|
| Let me elaborate my point.
|
| I have one function which i am executing on elapsed event of timer.
| I am expecting this function to be executed once a day so i set
| interval to execute it once a day. My application is working properly
| say for nearly 30 days.
|
| Suddenly instead of firing elasped event once a day timer getting fired
| per mins sometime per seconds also.
|
| I am strange why this is happening. Can you tell me reason behind
| this.
|
| Any help will be truely appreciated.
|
|
| Thanks in advance.
|
| ChrisM wrote:
| What exactly do you mean by behaving erratically?
| What is the expected timer interval, and what is actually happening?
| >
| Could there be somthing else in your program that is firing and maybe
| holding up processing, hence causing your timer event to run 'late'?
| As it happens after a while, could your program have a memory leak or
| somthing?
| >
| Strange that it still happens after re-starting the service! Does the
| program rely on anything else outside its 'domain' that could be causing
a
| problem?
| >
| "archana" <tr************ **@yahoo.comwro te in message
| news:11******** **************@ c28g2000cwb.goo glegroups.com.. .
| Hi all,
|
| thanks for reply.
|
| one more question is if i restarted my windows service still timer is
| behaving erractically.
|
| Actually after restart my application should start workin properly.
|
| To start application to work properly i have to restart my pc.
|
| can someone tell me reason behind this.
|
| Any help will be truely appreciated.
|
| thanks in advance.
|
|
Oct 5 '06 #10

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

Similar topics

3
16910
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects interval property inside the event handler? Example follows: Constructor: mTimer = new System.Timers.Timer(20000); mTimer.AutoReset = false;
4
3370
by: redneon | last post by:
I've set up a seperate thread and put a timer in it but for some reason it's tick event is never fired. This is what I have... .... Thread timerThread = new Thread(new ThreadStart(startTimer)); timerThread.Start(); .... private void startTimer() {
2
5160
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as I am new to this. Full code below : using System; using System.Collections; using System.ComponentModel;
9
7285
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
1
1793
by: Roland | last post by:
Hi, I have written a Windows Service with a Timer (System). The Interval is set to 60000 (60 seconds) for testing. In the Timer1_Elapsed event I execute a task. In this case I have to read a text file, draw data from a SQL server, and send it all out in an email every day at the same time. Problem is that the elapsed event fires anywhere from 1 time to 40
14
2564
by: Crirus | last post by:
This is more a logical problem than a VB. I have this situation: A timer that need to tick at each 10 minutes starting on minute 15 of curent hour. But I want to calculate the next tick time whenever I want to start the timer.
5
4916
by: muzilli | last post by:
Howdy all, I would like to know how can I insert a Timer object in my class library? This timer object will start and stop in a determinated part or event of my program. I know how to do this in Delphi or using a RAD tool and insert the Timer object in a form, but how to do in C# by hand and in a class library (without form), I don't know.
10
6478
by: hazz | last post by:
Is it possible to have the timer interval in a window's service be derived from an app.config setting? When I implemented one a while back I was forced to hard code the value because it wasn't working. There didn't appear to be any problem with the code that extracts the value from the key in the config file. Thanks, -hazz
19
2209
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 the timer: fire at 3:25 pm. What's the best way to accomplish that?
0
10140
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...
1
9935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9819
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
8821
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...
1
7364
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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
5268
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...
3
3519
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2790
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.