c# winform多线程实时更新控件

//创建委托        
private delegate void SetTextCallback(string text);
 
   ///
        /// 控件状态更新
        ///
        ///
        private void SetText(string text)
        {
            try
            {
                if (txt_RTPPacket.InvokeRequired)
                {
                    SetTextCallback setTextDele = SetText;
                    txt_RTPPacket.Invoke(setTextDele, new object[] { text });
                }
                else
                {
                    txt_RTPPacket.AppendText(text);
                    
                }
            }
            catch (Exception)
            {
            }
        }

转载于:https://www.cnblogs.com/innershare/p/10607826.html

你可能感兴趣的:(c# winform多线程实时更新控件)