测试使用

 

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()); }
                    }
                });
}

        }

 



posted @ 2019-06-17 15:42  荒野绿洲  阅读(45)  评论(0)    收藏  举报