我正在绘制一个来自serialport的标签文本。如何在不按下按钮的情况下从serialport获取数据?
这是我的代码
public string Read()
{
try
{
this.DataReceived = oSerialPort.ReadLine().ToString();
return (this.DataReceived);
}
catch
{
return "Failed";
}
}
private void button17_Click(object sender, EventArgs e)
{
Thread.Sleep(500);
string x = Read();
Label1.Text = x;
}