Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Overhead using System.Timers.Timer
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Overhead using System.Timers.Timer
Miscellaneous
Thread ID:
00940086
Message ID:
00940086
Views:
67
I am creating a Windows service that uses a timer (System.Timers.Timer) to perform some tasks at specific intervals.
In the OnStart of the Windows Service I create a new instance of my class:
protected override void OnStart(string[] args)
{
  oMyClass = new MyClass();
}
In the constructor of MyClass I start a new timer
public MyClass
{
  oTimer = new System.Timers.Timer();
  oTimer.Elapsed += new System.Timers.ElapsedEventHandler(oTimer_Elapsed);
  oTimer.Interval = 1000 * 25;
  oTimer.Start();
  oTimer_Elapsed(this,null);	
}
And now here comes the question: In addition to the things (thing#1) I want done every 25 seconds I also want some things (thing#2) done lets say every 100 seconds. Is there a lot of overhead accosiated with a timer object so that I should look into creating logic that does thing#2 every 4th time the timer fires (thing#1 is done) or should I add another timer with Interval = 1000 * 100 for thing#2?

Please comment on any other parts of how I set up my windows service.

Thanks,
Einar
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform