Created
August 24, 2018 07:51
-
-
Save PradeepLoganathan/a635234a65480b1b99e3da5f50adb84b to your computer and use it in GitHub Desktop.
A console timer sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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