标题:求助大神,在C#编程出现如下情况,请问该如何处理?
只看楼主
Raibows6618
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-11-4
结帖率:0
已结贴  问题点数:20 回复次数:1 
求助大神,在C#编程出现如下情况,请问该如何处理?

using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NationalInstruments;
using NationalInstruments.DAQmx;


namespace DAQ_Example
{
   
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }


        System.Timers.Timer timer2;



        private void button1_Click(object sender, EventArgs e)
        {


           
            timer2 = new System.Timers.Timer(100);
            timer2.AutoReset = true;
            timer2.Enabled = true;
            timer2.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Elapsed);



        }


        
        void timer2_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {

               // Control.CheckForIllegalCrossThreadCalls = false;


            Task temperatureTask = new Task();
            AIChannel myAIChannel;
            myAIChannel = temperatureTask.AIChannels.CreateThermocoupleChannel(
                "Dev1/ai0",
                "Temperature",
                0,
                100,
                AIThermocoupleType.J,
                AITemperatureUnits.DegreesC,
                25
                );

            AnalogSingleChannelReader reader = new
                AnalogSingleChannelReader(temperatureTask.Stream);

                //System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
                double analogDataIn = reader.ReadSingleSample();//出现问题的语句

                textBox1.Text = analogDataIn.ToString();
            

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
      
    }
}
搜索更多相关主题的帖子: public false 如何 
2016-11-04 21:08
向洪林
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:重庆市奉节县
等 级:版主
威 望:9
帖 子:118
专家分:405
注 册:2015-3-10
得分:20 
你确定reader.ReadSingleSample();是double类型吗??自己检查下是不是类型不对

新手上路,望大家多多照顾,谢谢!
2016-11-08 12:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-470723-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.363579 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved