コード例 #1
0
 private void ClosePort()
 {
     if (_access != null)
     {
         _access.Close();
         _access = null;
     }
     SerialPortOperate.ClosePort();
 }
コード例 #2
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     if (CanClose)
     {
         base.OnFormClosing(e);
     }
     else
     {
         if (!Para.StationGrade.Contains("台站"))
         {
             return;
         }
         if (e.CloseReason == CloseReason.UserClosing)
         {
             e.Cancel = true;
         }
         else
         {
             _serialPort?.ClosePort();
         }
     }
 }