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

Timers die... need help

Hi everybody.

Recently I ran into situation with System.Threading.Timer in my ASP.NET
application. I reinstalled Windows on one of my servers and got timers stop
firing events after while, they just stop functioning one-by-one.
Here is detailed explanation. I run application on 2 dedicated Win 2003
servers. Server A serves about 1000 active simultaneous users (150-200 aspx
page requests per second), Sever B serves about 400 users (80-100 aspx
requests per sec). Application is the same. Machine.config is identical.
maxWorkerThreads and maxIOThreads bumped to 40. minFreeThreads = 8. There
are about 25 static timers throuout the application and there are some
dynamicly created timers. Recently I realized that hosting company did not
install SP1 for some reason, but applied critical hotfixes. I asked to
reinstall OS on the servers, so far they did it on server B.
Now, after installing Win 2003 on server B, with SP1 and all recent
updates, and installing my application there, I'm getting my timers stop
working. Possible exceptions in timer events are silenced. Logging shows
that timers work normally for a few minutes and then next event just never
happens. If I force timer by calling it's Change method, it works for a few
minutes and then dies again.
Below is simplyfied code sample and a result log.
Again, it works fine on Win 2003 without servicepack, and does not on
Win 2003 SP1.
The timers are not accessed from any other place, they are being created
on app init and then managed in timed event method in timed event (see
code).
Eventlog does not show any threads being terminated.

Also, I noticed that even though .Net version is the same on servers A
and B (1.1.4322.573), the behavior is a bit different. In particular, on
server A bad viewstate causes exception with message "The viewstate is
invalid for this page and might be corrupted." while on server B exception
message includes as well client IP, requested URL, and viewstate.

Does anybody have any idea what all this about? Any hint? For now I had
to shut down server B and let server A handle all the work.
I've had similar problem with System.Timers.Timer before. Since I
switched to System.Threading.Timer, it was gone. And now... ups...

Code sample.

Global.asax.cs

namespace VR
{
public class Global : System.Web.HttpApplication
{
private Common.AppTimers appTimers;

protected void Application_Start(Object sender, EventArgs e)
{
appTimers = new Common.AppTimers();
}
}
}

vrTimers.cs

using System;
using System.Threading;

namespace VR.Common
{
public class AppTimers
{
private Timer tmTimedWork;
static private AppTimers appTimers;

public AppTimers()
{
try
{
VR.Logger.Log(VR.enumLogs.Logic, "Init timers");
tmTimedWork = new Timer(new TimerCallback(OnTimedWork),
null, 7000, 10000);
appTimers = this;
}
catch(Exception ee)
{
VR.Logger.Log(VR.enumLogs.Logic, "AppTimers(): " +
ee.Message);
throw;
}

}

public void OnTimedWork(object source)
{
VR.Logger.Log(VR.enumLogs.Trace, "OnTimedWork begin");

try
{
tmTimedWork.Change(120000, 600000);
lock(tmTimedWork)
{
long period = SomeClass.SomeStatic() * 1000;
tmTimedWork.Change(period, period);
VR.Logger.Log(VR.enumLogs.Trace, "OnTimedWork end
"+period.ToString());
}
}
catch (Exception ee)
{
tmTimedWork.Change(5000, 5000);
VR.Logger.Log(VR.enumLogs.Logic, "OnTimedWork:
"+ee.Message);
}
}

}
}

The log looks like this:
8/31/2005 4:37:46 AM: OnTimedWork begin
8/31/2005 4:37:46 AM: OnTimedWork end 1000
8/31/2005 4:37:47 AM: OnTimedWork begin
8/31/2005 4:37:47 AM: OnTimedWork end 1000
8/31/2005 4:37:48 AM: OnTimedWork begin
8/31/2005 4:37:48 AM: OnTimedWork end 1000
8/31/2005 4:37:49 AM: OnTimedWork begin
8/31/2005 4:37:49 AM: OnTimedWork end 1000
8/31/2005 4:37:50 AM: OnTimedWork begin
8/31/2005 4:37:50 AM: OnTimedWork end 1000
8/31/2005 4:37:51 AM: OnTimedWork begin
8/31/2005 4:37:51 AM: OnTimedWork end 1000
8/31/2005 4:37:52 AM: OnTimedWork begin
8/31/2005 4:37:52 AM: OnTimedWork end 1000
8/31/2005 4:37:53 AM: OnTimedWork begin
8/31/2005 4:37:53 AM: OnTimedWork end 1000
8/31/2005 4:37:54 AM: OnTimedWork begin
8/31/2005 4:37:54 AM: OnTimedWork end 1000

Dmitry.

Sep 1 '05 #1
0 1733

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

Similar topics

10
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have...
13
by: Bob | last post by:
My WinForms app runs on the single default thread, and uses a single SqlConnection object for all queries. I need to use one or more timers to periodically execute some of them. My own testing...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
8
by: Jerry Spence1 | last post by:
I am trying to create timers on demand by doing the following: Dim NewTimer As New System.Timers.Timer NewTimer.Interval = 10000 AddHandler NewTimer.Elapsed, AddressOf Timeup NewTimer.Enabled =...
0
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they...
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...
3
by: Steve Lowe | last post by:
Hi, I'm getting into VB.net with the help of a few books, but have got a problem grasping how to implement a system.timers.timer Only 1 of my 3 books mentions timers and that's a...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
2
by: BobAtVandy | last post by:
I'll greatly appreciate any help on this. Actually 2 questions: 1. I believe I need to use the Windows timer System.Timers.Timer . The examples I find on the web all access that timer by...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.