Mega Code Archive

 
Categories / C# Tutorial / Development
 

A Timer that fires once at the specified time

using System; using System.Threading; using System.Globalization; class MainClass {     public static void Main(string[] args)      {         TimeSpan waitTime = new TimeSpan(1000);         new Timer(delegate(object s) {                             Console.WriteLine("{0} : {1}",                             DateTime.Now.ToString("HH:mm:ss.ffff"), s);                         }                   , null, waitTime, new TimeSpan(-1));     } }