473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Timer stop working ?

Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.T imer 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_Elaps ed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elaps ed(object sender, System.Timers.E lapsedEventArgs
e)
{
DtmLastClock = System.DateTime .Now;

if ( NumFunction1_Ti merSteps 0 )
{
NumFunction1_St epsCount++;

if ( !BolFunction1_L ock && NumFunction1_St epsCount >=
NumFunction1_Ti merSteps )
{
BolFunction1_Lo ck = true;
NumFunction1_St epsCount = 0;
this.Function1( );
BolFunction1_Lo ck = false;
}
}

if ( NumFunction2_Ti merSteps 0 )
{
NumFunction2_St epsCount++;

if ( !BolFunction2_L ock && NumFunction2_St epsCount >=
NumFunction2_Ti merSteps )
{
BolFunction2_Lo ck = true;
NumFunction2_St epsCount = 0;
this.Function2( );
BolFunction2_Lo ck = false;
}
}
}

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

I've writed a C# windows service in VS 2003.
This service use a System.Timers.T imer 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_Elaps ed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elaps ed(object sender, System.Timers.E lapsedEventArgs
e)
{
DtmLastClock = System.DateTime .Now;

if ( NumFunction1_Ti merSteps 0 )
{
NumFunction1_St epsCount++;

if ( !BolFunction1_L ock && NumFunction1_St epsCount >=
NumFunction1_Ti merSteps )
{
BolFunction1_Lo ck = true;
NumFunction1_St epsCount = 0;
this.Function1( );
BolFunction1_Lo ck = false;
}
}

if ( NumFunction2_Ti merSteps 0 )
{
NumFunction2_St epsCount++;

if ( !BolFunction2_L ock && NumFunction2_St epsCount >=
NumFunction2_Ti merSteps )
{
BolFunction2_Lo ck = true;
NumFunction2_St epsCount = 0;
this.Function2( );
BolFunction2_Lo ck = 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.Threadin g.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********@gma il.comha scritto nel messaggio
news:11******** **************@ o80g2000hse.goo glegroups.com.. .
On Aug 21, 5:03 am, "Daniele Piccinini"
<daniele.piccin ...@nospam.nosp amwrote:
>Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.T imer 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_Elaps ed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?

Thanks.

- Dany -

The code ..

private void TmrSystem_Elaps ed(object sender,
System.Timers. ElapsedEventArg s
e)
{
DtmLastClock = System.DateTime .Now;

if ( NumFunction1_Ti merSteps 0 )
{
NumFunction1_St epsCount++;

if ( !BolFunction1_L ock && NumFunction1_St epsCount >=
NumFunction1_T imerSteps )
{
BolFunction1_Lo ck = true;
NumFunction1_St epsCount = 0;
this.Function1( );
BolFunction1_Lo ck = false;
}
}

if ( NumFunction2_Ti merSteps 0 )
{
NumFunction2_St epsCount++;

if ( !BolFunction2_L ock && NumFunction2_St epsCount >=
NumFunction2_T imerSteps )
{
BolFunction2_Lo ck = true;
NumFunction2_St epsCount = 0;
this.Function2( );
BolFunction2_Lo ck = 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.Threadin g.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.nosp amwrote:
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.T imer 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.Threadin g.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.nosp amwrote in message
news:uQ******** *****@TK2MSFTNG P02.phx.gbl...
Hallo,

I've writed a C# windows service in VS 2003.
This service use a System.Timers.T imer 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_Elaps ed 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(wa it 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
7494
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 it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
3
16907
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;
7
33585
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 form and it works fine, but in the service: nothing. .... this.components = new System.ComponentModel.Container(); this.tmrTimer = new System.Windows.Forms.Timer(this.components); // // tmrTimer //
2
13191
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 disposed, do not seem to end their thread after the timers stop working). For instance, when making a simple timer with the following code: public System.Threading.Timer timerTest; public System.Threading.TimerCallback tCallBack;
3
7839
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 contain a definition for 'Tick' So what should i do??? the final thing I wanna get is, I have a console will call a exe running in background, and then I wanna check it is is still running ( Use get process
14
2562
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.
6
3333
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, the Timer component (the one found at System.Windows.Forms.Timer) starts ticking (with this code: Timer.Enabled = True). Whenever the timer ticks, 'intTime' is inclemented by 1 and this updated number is displayed on the form. The interval of the...
17
1877
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
2600
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 library as I thought this would be a good start!!!) but nothing happens :- Imports System.Timers
0
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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...
0
9241
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
8239
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
6793
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
6073
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();...
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2211
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.