winform线程给lable赋值

 /// <summary>
        /// 线程给lable赋值
        /// </summary>
        /// <param name="value"></param>
        private delegate void SetTextDelegate(string value);
        private void WriteLabel(string s)
        {
            if (label1.InvokeRequired)
            {
                SetTextDelegate d = new SetTextDelegate(WriteLabel);
                label1.Invoke(d, new object[] { s });
            }
            else
            {
                label1.ForeColor = Color.Red;
                label1.Text = s;
            }
        }

 

posted @ 2011-11-05 16:01  放哨De老鼠  阅读(1300)  评论(0编辑  收藏  举报