Return to Snippet

Revision: 19818
at October 31, 2009 22:32 by rtipton


Initial Code
using System;
using System.Timers;

public class Program
{
    private static System.Timers.Timer testTimer;

    public static void Main(string[] args)
    {
        testTimer = new System.Timers.Timer(5000); // 5 seconds
        testTimer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);

        testTimer.Interval = 5000;
        testTimer.Enabled = true;

        Console.WriteLine("Press the enter key to stop the timer");
        Console.ReadLine();

    }

    private static void OnTimerElapsed(object source, ElapsedEventArgs e)
    {
        Console.WriteLine("Timer elapsed at {0}", e.SignalTime);
    }
}

Initial URL


Initial Description
1 of the 3 types of timers in the .net framework

Initial Title
System.Timers.Timer Example

Initial Tags


Initial Language
C#