问题终于解决,
原来一开始没做rapi是否已经连接PDA的判定,导致一直出现合格错误
private bool mcConnected = false;
private void timer1_Tick(object sender, EventArgs e)
{
if (this.connectMC())
{
this.button1.Enabled = true;
//this.bt_import.Enabled = true;
this.mcConnected = true;
this.tLabel1.Text = "连接状态:设备已连接!" + DateTime.Now.ToString();
}
else
{
this.button1.Enabled = false;
//this.bt_import.Enabled = false;
if (this.mcConnected)
{
this.mcConnected = false;
this.tLabel1.Text = "连接状态:设备已断开连接!" + DateTime.Now.ToString();
}
}
}
private bool connectMC()
{
if (this.rapi.DevicePresent)
{
if (!this.rapi.Connected)
{
this.rapi.Connect();
}
return true;
}
return false;
}