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

Why Timer stop working ?

Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.Timer to periodically call some functions
of a web service.
( Some of this functions required minutes to be executed ).
The timer interval is 1 sec, and each functions 'counts' his number of timer
clock to know when it must be executed.
Sometimes happen that the service don't do his works. I stop the service and
watching the log i note thath the timer has stop 'clocking' some hour ago
( i save the last clock datetime in TmrSystem_Elapsed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
DtmLastClock = System.DateTime.Now;

if ( NumFunction1_TimerSteps 0 )
{
NumFunction1_StepsCount++;

if ( !BolFunction1_Lock && NumFunction1_StepsCount >=
NumFunction1_TimerSteps )
{
BolFunction1_Lock = true;
NumFunction1_StepsCount = 0;
this.Function1();
BolFunction1_Lock = false;
}
}

if ( NumFunction2_TimerSteps 0 )
{
NumFunction2_StepsCount++;

if ( !BolFunction2_Lock && NumFunction2_StepsCount >=
NumFunction2_TimerSteps )
{
BolFunction2_Lock = true;
NumFunction2_StepsCount = 0;
this.Function2();
BolFunction2_Lock = false;
}
}
}

Aug 21 '07 #1
7 8606
On Aug 21, 5:03 am, "Daniele Piccinini"
<daniele.piccin...@nospam.nospamwrote:
Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.Timer to periodically call some functions
of a web service.
( Some of this functions required minutes to be executed ).
The timer interval is 1 sec, and each functions 'counts' his number of timer
clock to know when it must be executed.
Sometimes happen that the service don't do his works. I stop the service and
watching the log i note thath the timer has stop 'clocking' some hour ago
( i save the last clock datetime in TmrSystem_Elapsed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
DtmLastClock = System.DateTime.Now;

if ( NumFunction1_TimerSteps 0 )
{
NumFunction1_StepsCount++;

if ( !BolFunction1_Lock && NumFunction1_StepsCount >=
NumFunction1_TimerSteps )
{
BolFunction1_Lock = true;
NumFunction1_StepsCount = 0;
this.Function1();
BolFunction1_Lock = false;
}
}

if ( NumFunction2_TimerSteps 0 )
{
NumFunction2_StepsCount++;

if ( !BolFunction2_Lock && NumFunction2_StepsCount >=
NumFunction2_TimerSteps )
{
BolFunction2_Lock = true;
NumFunction2_StepsCount = 0;
this.Function2();
BolFunction2_Lock = false;
}
}

}- Hide quoted text -

- Show quoted text -
Hi Daniele,
I'm not sure it applies to your situation, but you might want to check
out this article:
FIX: When a .NET Framework based application uses the
System.Threading.Timer class, the timer event may not be signaled in
the .NET Framework 1.1 SP1

http://support.microsoft.com/?id=900822

I ran into this a while back when I had timers that stopped firing.
Hope it helps,
John

Aug 21 '07 #2

"John Duval" <Jo********@gmail.comha scritto nel messaggio
news:11**********************@o80g2000hse.googlegr oups.com...
On Aug 21, 5:03 am, "Daniele Piccinini"
<daniele.piccin...@nospam.nospamwrote:
>Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.Timer to periodically call some
functions
of a web service.
( Some of this functions required minutes to be executed ).
The timer interval is 1 sec, and each functions 'counts' his number of
timer
clock to know when it must be executed.
Sometimes happen that the service don't do his works. I stop the service
and
watching the log i note thath the timer has stop 'clocking' some hour ago
( i save the last clock datetime in TmrSystem_Elapsed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elapsed(object sender,
System.Timers.ElapsedEventArgs
e)
{
DtmLastClock = System.DateTime.Now;

if ( NumFunction1_TimerSteps 0 )
{
NumFunction1_StepsCount++;

if ( !BolFunction1_Lock && NumFunction1_StepsCount >=
NumFunction1_TimerSteps )
{
BolFunction1_Lock = true;
NumFunction1_StepsCount = 0;
this.Function1();
BolFunction1_Lock = false;
}
}

if ( NumFunction2_TimerSteps 0 )
{
NumFunction2_StepsCount++;

if ( !BolFunction2_Lock && NumFunction2_StepsCount >=
NumFunction2_TimerSteps )
{
BolFunction2_Lock = true;
NumFunction2_StepsCount = 0;
this.Function2();
BolFunction2_Lock = false;
}
}

}- Hide quoted text -

- Show quoted text -

Hi Daniele,
I'm not sure it applies to your situation, but you might want to check
out this article:
FIX: When a .NET Framework based application uses the
System.Threading.Timer class, the timer event may not be signaled in
the .NET Framework 1.1 SP1

http://support.microsoft.com/?id=900822

I ran into this a while back when I had timers that stopped firing.
Hope it helps,
John
Thank you John, the problem may be this.
The service is installed on Windows Server 2003 sbs sp1. Do i need to
install Windows server 2003 sp2 or (better) do you know if there is an
update of the framework ?
Thanks

- Dany -

Aug 21 '07 #3
On Aug 21, 4:44 pm, "Daniele Piccinini"
<daniele.piccin...@nospam.nospamwrote:
The service is installed on Windows Server 2003 sbs sp1. Do i need to
install Windows server 2003 sp2 or (better) do you know if there is an
update of the framework ?
Also see the following, which may be relevant to your situation:

BUG: The Elapsed event of the System.Timers.Timer class is not raised
in a Windows service

http://support.microsoft.com/kb/842793

(although I'm not sure I believe the commentary in the steps to repro
in that linked article.)
Matt

Aug 21 '07 #4
Thank for Matt's informative input.

Hi Daniele,

I think the further bug entry Matt has refered could be helpful to you:

#FIX: When a .NET Framework based application uses the
System.Threading.Timer class, the timer event may not be signaled in the
.NET Framework 1.1 SP1
http://support.microsoft.com/kb/900822/

If feel the problem you met is aligned to the bug entry, you can directly
contact the CSS (follow the link in the kb) and request for the hotfix.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.





Aug 22 '07 #5

"Daniele Piccinini" <da***************@nospam.nospamwrote in message
news:uQ*************@TK2MSFTNGP02.phx.gbl...
Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.Timer to periodically call some functions
of a web service.
( Some of this functions required minutes to be executed ).
The timer interval is 1 sec, and each functions 'counts' his number of
timer clock to know when it must be executed.
Sometimes happen that the service don't do his works. I stop the service
and watching the log i note thath the timer has stop 'clocking' some hour
ago ( i save the last clock datetime in TmrSystem_Elapsed event handler
and i log this value in the service OnStop function ).
Someone have an idea ?
I don't like using Timers in a NT Service, because of the reasons you're
posting about.

I always spawn a thread and use a Thread.Sleep(wait time) in a While True
Loop to execute code on a timed basis in a NT Service application.

Aug 22 '07 #6

Thank you Steven. Now i contact the CSS and request for the hotfix.

- Dany -
Aug 24 '07 #7
Thank you Arnold, this is a good idea.

- Dany -
Aug 24 '07 #8

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

Similar topics

13
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...
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...
7
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...
2
by: Amadej | last post by:
Hello everyone I have a beginner's questions about the System.Threading.Timer class behavior. I have been observing the thread count with Windows Task Manger and noticed that timers, after being...
3
by: jam | last post by:
Dear all, I am wrtiing a console application and doing some test on timer, the below is my sample code I got from some site, but I cannot make it work... Error is 'System.Timers.Timer' does not...
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...
6
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
17
by: Ratnesh Raval | last post by:
hi all, i m having some problem in timer control. sub timer.tick() timer.stop() do...something timer.enabled = true end sub
11
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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
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...
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.