Hello Lets say I have a console application, that looks like this
class Program
{
static void Main(string[] args)
{
}
public void DoSomething()
{
Console.WriteLine("Hello World");
}
}
}
I wan't to execute my DoSomething method every 10'th second by using System.Threading.timer. Can anyone give an example of how that is done?
Thanks in advance :)
System.Threading.Timer
类的文档页面有一个冗长的好例子。
Timer timer1 = new Timer(10000);
timer1.Enabled = true;
timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
timer1.Start();
static void timer1_Elapsed(object sender, ElapsedEventArgs e)
{
//Do Something
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.