c#解决窗体假死的一种方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c#解决窗体假死的一种方法相关的知识,希望对你有一定的参考价值。

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            CheckForIllegalCrossThreadCalls = false;
            this.label1.Text = "aaaaa";
         
            Thread tr = new Thread(testc);
            tr.Start();
        }

        private void testc()
        {
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(10000);
                MessageBox.Show("a");
            }
        }
    }

 

以上是关于c#解决窗体假死的一种方法的主要内容,如果未能解决你的问题,请参考以下文章