测试使用
private void button1_Click(object sender, EventArgs e)//启动按钮
{
if (thread == null)
{
thread = new Thread(() =>
{
while (true)
{
index++;
try
{
Thread.Sleep(1000);
textBox1.Invoke(new Action(() =>
{
textBox1.AppendText($"第{index}次,");
}));
}
catch (Exception ex) { MessageBox.Show(ex.ToString()); }
}
});
}
}

浙公网安备 33010602011771号