Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Created August 24, 2018 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/a635234a65480b1b99e3da5f50adb84b to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/a635234a65480b1b99e3da5f50adb84b to your computer and use it in GitHub Desktop.
A console timer sample
using System;
using System.Timers;
namespace thetime
{
class Program
{
static void Main(string[] args)
{
var timer = new Timer(2000);
timer.AutoReset = true;
timer.Enabled = true;
timer.Elapsed += Timer_Elapsed;
Console.ReadLine();
timer.Stop();
timer.Dispose();
}
private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Console.WriteLine("Timer fired at {0}", DateTime.Now.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment