检查某个复选框时,我遇到串行逗号分隔变量的问题。我希望数据流不断流向arduino,即使变量没有变化也是如此。我唯一能够得到任何接近的东西,我陷入了无限循环。这是我目前的代码,任何帮助将不胜感激。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;
namespace feeder3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void streamBox_CheckedChanged(object sender, EventArgs e)
{
int a = 1;
int b = 2;
int c = 3;
bool state = streamBox.Checked;
while (state == true)
{
System.Console.WriteLine("{0},{1},{2}", a,b,c);
}
}
private void stopStreamBtn_Click(object sender, EventArgs e)
{
streamBox.Checked = false;
}
}
}
答案 0 :(得分:0)
我想通过使用信息barny给了我。我现在可以调整延迟以匹配波特率。
private async void streamBox_CheckedChanged(object sender, EventArgs e) { int a = 1; int b = 2; int c = 3; bool state = streamBox.Checked; while (state == true) { System.Console.WriteLine("{0},{1},{2}", a,b,c); await Task.Delay(10); } }