A timer with c# console
Im using c# console . I have a timer like : int TimeElasped = 0 ,,,, to
show and update times . it can resolve with a
for( ; ; )
but computer cant do other codes !!! so I am using this code :
using System.Threading;
public class Test
{
static int TimeElasped = 0;
static void Main(string[] args)
{
Timer tm = new
Timer(tm_tick,null,TimeSpan.FromSeconds(1),TimeSpan.FromSeconds(1));
Console.Write("");
Console.ReadKey();
}
static void tm_tick(object obj)
{
Console.Clear();
Console.WriteLine("Timer:{0}", TimeElasped );
Counter++;
}
}
I Cannot use Console.Clear() because it clear all data in console , when i
remove Console.Clear() timer is showing line by line !!!
so how can i have a timer that update time ?
thanks ,
No comments:
Post a Comment