110,539
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e)
{
LoopButton();
}
private void LoopButton()
{
ThreadPool.QueueUserWorkItem(obj =>
{
this.Invoke((Action)(() =>
{
button1.Enabled = false;
button1.Text = "10";
}));
int time = 10;
while (time > 0)
{
Thread.Sleep(1000);
this.Invoke((Action)(() =>
{
button1.Text = (--time).ToString();
}));
}
this.Invoke((Action)(() =>
{
button1.Enabled = true;
}));
});
}