using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
            Thread thread = new Thread(UpdateLabel);
        private void button1_Click(object sender, EventArgs e)
        {
            thread.Start();
        }        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
        }        public static void UpdateLabel()
        {
           button1.Text = "fyf";  //报错
        }    }
}

解决方案 »

  1.   

    this.invoke
      

  2.   


    this.begininvok(()=>{
    this.text="aaa";
    })
    like this?
      

  3.   

    楼上真可以!
    都 static 了,哪来的 this
      

  4.   

    新开一线程来设置
    ThreadPool.QueueUserWorkItem(new WaitCallback(a => { lb.Text = "123"; }));
      

  5.   

    MFC的static线程可以C#怎么弄啊,我想开一个全局的线程,所有的控件都能调用才行啊
      

  6.   

    开在program.cs里面啊………………