C#跨线程访问Button控件

        private void button2_Click(object sender, EventArgs e)
        {
          //  button1.BackColor = SystemColors.ButtonHighlight;
            System.Threading.Thread userThead = new System.Threading.Thread(new System.Threading.ThreadStart(ChangeBackGround));
            userThead.IsBackground = true;
            userThead.Start();
 
        }
        private void ChangeBackGround()
        {
           // button1.BackColor = SystemColors.ButtonHighlight;
            //button1.BeginInvoke((Action)(() => button1.BackColor = SystemColors.ButtonHighlight));
            button1.BeginInvoke((MethodInvoker)(() => button1.BackColor = SystemColors.ButtonHighlight));
 
        }
posted @ 2013-05-05 18:31  Predator  阅读(528)  评论(0编辑  收藏  举报