110,536
社区成员
发帖
与我相关
我的任务
分享
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private System.Threading.Timer timer;
private int num=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer = new System.Threading.Timer(new TimerCallback(Time_Elapsed), this, 0, 10000);
}
void Time_Elapsed(object sender)
{
string n;
n = num.ToString();
textBox1.Text = "n";//
num++;
timer.Change(Timeout.Infinite, 1000);
}
}
}
void Time_Elapsed(object sender)
{
string n;
n = num.ToString();
//此处设置了断点,不过程序没有停止下来。
Console.Out.WriteLine(DateTime.Now + " " + DateTime.Now.Millisecond.ToString() + n);
//textBox1.Text = "n";//
num++;
timer.Change(Timeout.Infinite, 1000);
}