469,572 Members | 1,329 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

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 2440
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.Interval = 2000;// of whatever your required interval is
myTimer.Tick +=new EventHandler(myTimer_Tick);//of whatever the method the
timer calls is called...
}

"archana" <tr**************@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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.Threading.Timer if you are
using System.Timers.Timer 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.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.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.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.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_doTheWorkTimer 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(AddressOf BeepClass.GoBeep)

m_doTheWorkTimer = New Timer(timerHandler , 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.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.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.WriteLine("Running a job every 5 seconds.");
System.Threading.Timer timer = null;
timer = new System.Threading.Timer(
delegate(object state)
{
timer.Change(5000, -1);
Console.WriteLine("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.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.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.comwrote in message
| news:11**********************@c28g2000cwb.googlegr oups.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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Peter Johnsson | last post: by
4 posts views Thread by redneon | last post: by
2 posts views Thread by Besta | last post: by
14 posts views Thread by Crirus | last post: by
19 posts views Thread by adi | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.