您的位置:首页 > 其它

多线程操作控件属性和方法

2020-08-11 16:46 253 查看

设置属性和方法

[code]private void button2_Click(object sender, EventArgs e)
{
timer.Stop();
Thread thread = new Thread(() =>
{
//this.label1.Text = i.ToString();
if (this.button1.InvokeRequired)
{
this.button1.Invoke(new Action(() => this.button1.Enabled = true));
}
Thread.Sleep(300);
});
thread.IsBackground = true;
thread.Start();
}

private void button3_Click(object sender, EventArgs e)
{
Thread thread = new Thread(() =>
{
if (this.richTextBox1.InvokeRequired)
{
this.richTextBox1.Invoke(new Action(() => this.richTextBox1.Clear()));
}
Thread.Sleep(300);
});
thread.IsBackground = true;
thread.Start();
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: