Пример #1
0
 /// <summary>
 /// 参数线程 定时执行
 /// 1. 获取测量结果 更新UI
 /// 2. 下发板卡参数
 /// </summary>
 private void StartUIThread()
 {
     Task.Factory.StartNew(() => {
         while (true)
         {
             if (CurrentBoltClient.TcpConnFlag == 0)
             {
                 Thread.Sleep(5000);
             }
             else
             {
                 // 注:子线程要获取主线程UI 需经过Dispacther.Invoke
                 Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                                            new Action(() => {
                     AxialForce.Text = CurrentBoltClient.boltData.axialForce.ToString();
                     TimeDelay.Text  = CurrentBoltClient.boltData.timeDelay.ToString();
                     MaxXcorr.Text   = CurrentBoltClient.boltData.maxXcorr.ToString();
                     CurrentBoltClient.boltData.pulsWidt   = Convert.ToDouble(pulsWidt.Text);
                     CurrentBoltClient.boltData.exciVolt   = Convert.ToDouble(exciVolt.Text);
                     CurrentBoltClient.boltData.prf        = Convert.ToDouble(prf.Text);
                     CurrentBoltClient.boltData.damping    = Convert.ToDouble(damping.Text);
                     CurrentBoltClient.boltData.lstGain[0] = Convert.ToDouble(GainText.Text);
                     CurrentBoltClient.boltData.Ks         = Convert.ToDouble(Ks.Text);
                     CurrentBoltClient.boltData.KT         = Convert.ToDouble(KT.Text);
                     CurrentBoltClient.boltData.T0         = Convert.ToDouble(ZeroTem.Text);
                     CurrentBoltClient.boltData.T1         = Convert.ToDouble(TestTem.Text);
                 }));
                 CurrentBoltClient.SetPara();
                 Thread.Sleep(1000);
             }
         }
     });
 }