I always use system.threading.timer with good luck. I create a new timer
each time to head off a few issues (i.e. 49 day issue, and overlapped jobs).
public void DoIt()
{
Timer t = null;
t = new Timer(
delegate(object state)
{
t.Dispose(); // t is "captured", so we don't need to hold it
elsewhere.
// Run your stuff.
DoIt();
}, null, 1000, -1));
}
Looks like stack recursion, but is not as we start async timer and return.
We schedule a new timer each time and only after we run the work so we don't
have danger of overlapped jobs. However, the next job only starts after the
previous one is finished, so that could be more then 1 second. You can
wiggle the ms's as needed.
--
William Stacey [C# MVP]
PCR concurrency library:
www.codeplex.com/pcr
PSH Scripts Project
www.codeplex.com/psobject
"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@y80g2000hsf.googlegro ups.com...
| On Mar 30, 3:43 pm, "Nicholas Paldino [.NET/C# MVP]"
| <m...@spam.guard.caspershouse.comwrote:
| DaTurk,
| >
| What you want is the Timer class in the System.Timers class.
| >
| Hope this helps.
| >
| --
| - Nicholas Paldino [.NET/C# MVP]
| - m...@spam.guard.caspershouse.com
| >
| "DaTurk" <mmagd...@hotmail.comwrote in message
| >
| news:11**********************@d57g2000hsg.googlegr oups.com...
| >
| >
| >
| Hi,
| >
| I'm creating an application that will need to use a timer to do a
| static method call every second. My question, is what would be the
| best timer to use? I know there are several, but I'd like to use a
| timer that is probably the most reliable, and hopefully designed with
| high performance in mind. Thank you in advance.- Hide quoted text -
| >
| - Show quoted text -
|
| Would System.Timer be the best choice? I need the most reliable, and
| high performance.
|