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

Timer Elapsed Firing Twice

I have a service that is driven by a timer that fires every 5 seconds.
For the most part, it works fine. But every once in a while the timer
fires twice. In the log I can see that when it fires twice, there are
two threads running. This causes problems so I need to find a way to
fix it.

So, my question is, do I need to use a Monitor to lock in my
timer_elapsed event handler?

Thanks for any advice...

Brian
Dec 21 '05 #1
4 7779
What sort of timer did you use? I had problems with the timer present
in the toolbox due to changes in controls on the form getting in the
way of the timer's elapsed method. I'm wondering if the timer is firing
twice because the first time it should have been firing something else
was happening.

Switching to a System.Timers.Timer solved the issues that I had.

Greg.

Dec 21 '05 #2

I am using a System.Timers.Timer.

It is a windows service, so it isn't form based.

Thanks for the thought, tho.

-B
Greg wrote:
What sort of timer did you use? I had problems with the timer present
in the toolbox due to changes in controls on the form getting in the
way of the timer's elapsed method. I'm wondering if the timer is firing
twice because the first time it should have been firing something else
was happening.

Switching to a System.Timers.Timer solved the issues that I had.

Greg.

Dec 21 '05 #3
Hi,
Maybe what happen is that in those moments the timer handler takes more than
5 seconds from the moment the timer elapsed for the last time.
a lock may be of help here.
cheers

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brian P" <no******@all.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a service that is driven by a timer that fires every 5 seconds. For
the most part, it works fine. But every once in a while the timer fires
twice. In the log I can see that when it fires twice, there are two
threads running. This causes problems so I need to find a way to fix it.

So, my question is, do I need to use a Monitor to lock in my timer_elapsed
event handler?

Thanks for any advice...

Brian

Dec 21 '05 #4

From my log, it seems that the two timer events occur concurrently.
It's almost as if the timer firest two elapsed events at the same time.
Because the work occurs in two different threads. (One for each event?)

I did add a lock and we'll see what that does..

--Brian
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
Maybe what happen is that in those moments the timer handler takes more than
5 seconds from the moment the timer elapsed for the last time.
a lock may be of help here.
cheers

Dec 22 '05 #5

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

Similar topics

3
by: David | last post by:
Hi There! I'm using Timer control to record how long my application perform certain tasks. However, apparently Timer control is not doing its' job (i.e. Not firing Tick event) while my...
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;...
4
by: Dan | last post by:
Hi, I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have elapsed without any user activity I want...
11
by: Philip Wagenaar | last post by:
Hello, I am using a timer object in my Windows Forms Application. Does the code in ..elapsed event run in a diffrent thread? If the interval is set to 10 milliseconds and the time to execute the...
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...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
9
by: archana | last post by:
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...
1
by: Adam Benson | last post by:
Hi, We have figured out that System.Timers.Timer should be avoided because it occasionally stops firing. So, we dutifully began switching over to System.Threading.Timer but somebody at work...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.