How do you add a timer to a C# console application
How do you add a timer to a C# console application:
However, the style of using a for loop to do some functionality forever takes a lot of device resources and instead we can use the Garbage Collector to do some thing like that.
For the use of timer in C# use fallowing :
using System;
using System.Threading;
We can see this modification code in the code in C#
using System;
using System.Threading;
public static class Program
{
public static void Main()
{
// Create a Timer object that knows to call our TimerCallback
// method once every 2000 milliseconds.
Timer t = new Timer(TimerCallback, null, 0, 2000);
// Wait for the user to hit <Enter>
Console.ReadLine();
}
private static void TimerCallback(Object o)
{
// Display the date/time when this method got called.
Console.WriteLine("In TimerCallback: " + DateTime.Now);
// Force a garbage collection to occur for this demo.
GC.Collect();
}
}
Asp.net related other Post :
Calculate Monthly Payments by the given formula in C# console Application
Retrieving current page number and total pages from Crystal Report
Show message box in asp.net for display total no of pages in crystal report
Set MaxLength property of asp.net multiline textbox
On page connection in asp.net with c#
Edit update delete in gridview in asp.net in template
Understanding controllers in Asp.net MVC
Action Method in Asp.net MVC Controller
Controllers and Action Methods in ASP.NET MVC Applications
Asp.net Step By Step Working with MVC3
Asp.net with c# example - datetime day of week
Asp.net web Development related Important Post List
Why the web.cofig file is very important (The Role Manager feature has not been
enabled.)
Example of Asp.net PlaceHolder Server Control
Comments
Post a Comment