private async void toolStripButtonStart_Click(object sender, EventArgs e) { bool bRet = false; if ("开始" == toolStripButtonStart.Text) { bRet = await m_flowSensor.StartAsync(); // 启动 } else //if ("停止" == toolStripButtonStart.Text) { bRet = await m_flowSensor.StopAsync(); // 停止 } if (bRet) { if ("开始" == toolStripButtonStart.Text) { bRet = await m_flowSensor.ZeroingAsync(); // 归零 if (bRet) { // 归零成功 toolStripButtonStart.Text = "停止"; toolStripButtonSavePresure.Enabled = false; toolStripButtonLoadPresure.Enabled = false; toolStripButtonClear.Enabled = false; toolStripButtonApply.Enabled = false; //ClearAll(); /* 尝试清空数据队列 */ TryClearDataQueue(); /* 监听流量传感器数据收取事件 */ m_flowSensor.PresureRecved += OnPresureRecved; /* 启动刷新定时器 */ m_refreshTimer.Start(); } } else // if ("停止" == toolStripButtonStart.Text) { toolStripButtonStart.Text = "开始"; toolStripButtonSavePresure.Enabled = true; toolStripButtonLoadPresure.Enabled = true; toolStripButtonClear.Enabled = true; toolStripButtonApply.Enabled = m_calParamAviable; /* 取消监听流量传感器数据收取事件 */ m_flowSensor.PresureRecved -= OnPresureRecved; /* 停止刷新定时器 */ m_refreshTimer.Stop(); /* 尝试清空数据队列 */ TryClearDataQueue(); } } }