在获取数据时使用 Winforms UI

问题描述

我使用 C# 开发表单应用程序。此应用程序将从光谱仪设备收集数据。当我设置连续采集时,我无法在采集过程中执行其他操作。我想在采集发生时缩放图表并执行其他操作。现在,当我单击缩放按钮时,它仅在采集结束后启用。请帮我解决这个问题。

请查看部分代码,其中有一个按钮单击以开始获取。一张图表也使用光谱仪的值进行更新。 UI 的屏幕截图也在底部

 private void button2_Click(object sender,EventArgs e)
    {
        while (true)
        {
            this.Refresh();
            int numberOfPixels; // number of CCD elements
            double[] spectrum;
            spectrum = null;   // spectrometerIndex = 0;

            if (spectrometerIndex == -1)
                return; // no available spectrometer

            numberOfPixels = wrapper.getNumberOfPixels(spectrometerIndex);
            wrapper.setBoxcarWidth(spectrometerIndex,0);
            wrapper.setCorrectForElectricalDark(spectrometerIndex,1);
            wrapper.setIntegrationTime(spectrometerIndex,1000); // acquisition time in microsecs

            int acquiretime = 100;
            if (textBoxin.Text != "")

            {
                int.TryParse(textBoxin.Text,out acquiretime); //arbitrary acquiretime

            }

            Stopwatch integrate = new Stopwatch();
            integrate.Start();
            while (integrate.Elapsed < TimeSpan.FromMilliseconds(acquiretime))
            {
                this.Refresh();
                spectrum = (double[])wrapper.getSpectrum(spectrometerIndex); data from spectrometer

            }

            integrate.Stop();
        }
    }

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)