473,398 Members | 2,427 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,398 software developers and data experts.

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 2626
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
4
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));...
2
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...
9
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;...
1
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...
14
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...
5
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...
10
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...
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...
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
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
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,...
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
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...
0
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,...
0
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...

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.