跨线程控件委托输出

 1 #region DataGrid 跨线程委托输出显示方法 姜彦20180315 1439
 2         /// <summary>
 3         /// DataGrid控件直接接受串口返回数据委托
 4         /// </summary>
 5         /// <param name="e"></param>
 6         public delegate void DataGridReceiverDelegate(TSerialPortController.ReceivedEventArgs e);
 7         public void DataGridReceiver(TSerialPortController.ReceivedEventArgs e)
 8         {
 9             FrameContent frameData = new FrameContent();
10             frameData.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
11             frameData.DataContent = e._ReceiveData;
12             _FrameContents.Add(frameData);
13         }
14         public void DataGridReceiverShow(TSerialPortController.ReceivedEventArgs e)
15         {
16             this.dgFormula.Dispatcher.Invoke(new DataGridReceiverDelegate(DataGridReceiver), e);
17         }
18 
19         /// <summary>
20         /// DataGrid控件输出FrameContent对象委托
21         /// </summary>
22         /// <param name="frameContent"></param>
23         public delegate void DataGridTextBoxShowDelegate(FrameContent frameContent);
24         public void DataGridTextBox(FrameContent frameContent)
25         {
26             _FrameContents.Add(frameContent);
27             dgFormula.ScrollIntoView(_FrameContents[_FrameContents.Count - 1], dgFormula.Columns[0]);//滚动条自动跟踪 姜彦20180315 1929
28         }
29 
30         /// <summary>
31         /// 将数据显示到DataGrid表格中
32         /// </summary>
33         /// <param name="frameContent"></param>
34         public void DataGridTextBoxShow(FrameContent frameContent)
35         {
36             this.dgFormula.Dispatcher.Invoke(new DataGridTextBoxShowDelegate(DataGridTextBox), frameContent);
37         }
38 
39 
40         #endregion

 

 1 #region CheckBox计数跨线程委托输出方法
 2 
 3         /// <summary>
 4         /// CheckBox接收数据计数委托
 5         /// </summary>
 6         /// <param name="count"></param>
 7         private delegate void CboxCountShowDelegate(int count);
 8         private void CboxCount(int count)
 9         {
10             if (cboxCount.IsChecked == true)
11             {
12                 cboxCount.Content = "计数:" + count.ToString();
13             }
14         }
15 
16         /// <summary>
17         /// CheckBox计数显示
18         /// </summary>
19         /// <param name="count"></param>
20         private void CboxCountShow(int count)
21         {
22             this.cboxCount.Dispatcher.Invoke(new CboxCountShowDelegate(CboxCount), count);
23         }
24 
25         #endregion

 

转载于:https://www.cnblogs.com/jiangyan219/articles/8576895.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值