多线程尝试

public partial class Form1 : Form
    {
        Thread m;
        int i = 0;
        public Form1()
        {
            InitializeComponent();
           
        }
        void ric()
        {
            while (true)
            {
                i++;
                richTextBox1.Text += i + "\r\n";
                Thread.Sleep(1000);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            m = new Thread(new ThreadStart(ric));
            m.Start();
        }
    }

体会  1. 多线程需要配合 循环(while)使用;

    2.跨线程调用窗体解决办法之一:Control.CheckForIllegalCrossThreadCalls = false;

posted on 2014-05-15 17:47  13m0n  阅读(123)  评论(0编辑  收藏  举报