Last active
October 25, 2018 04:05
-
-
Save diaolizhi/5f087540d445dcf8a2f289410c46db62 to your computer and use it in GitHub Desktop.
C# 定时回调委托
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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