Skip to content

Instantly share code, notes, and snippets.

@diaolizhi
Last active October 25, 2018 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diaolizhi/5f087540d445dcf8a2f289410c46db62 to your computer and use it in GitHub Desktop.
Save diaolizhi/5f087540d445dcf8a2f289410c46db62 to your computer and use it in GitHub Desktop.
C# 定时回调委托
public Form1()
{
//TimerCallback 是委托类型,可以关联一个形参为 Object 的函数
TimerCallback timerCallback = new TimerCallback(timeUpdate);
//Timer 每隔 1000ms 调用委托
System.Threading.Timer timer = new System.Threading.Timer(timerCallback, "", 0, 1000);
}
public void timeUpdate(Object obj)
{
//label1.Text = DateTime.Now.ToString();
MessageBox.Show("test");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment