Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Overhead using System.Timers.Timer
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00940086
Message ID:
00940420
Vues:
17
Einar,

Timers are pretty efficient. They're basically a threading mechanism that fires off new threads (or threadpool threads really). If I remember right these timers are pretty close to underlying OS APIs so there's very little overhead for them, especially in low firing intervals as yours (many seconds).

Remember too that timers fire events on a separate thread, so they don't genearlly hold up the main app. Just make sure you keep the code in the handler simple and quick and if it's not to utilize Application.DoEvents() liberally.

+++ Rick ---

>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
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform