public void Dispose() { if (samplingTimer != null) { samplingTimer.Stop(); samplingTimer.Enabled = false; samplingTimer.Dispose(); } if (commPort != null) { commPort.Close(); commPort.Dispose(); } }
/// <summary> /// Releases comm port and related managed resources. /// </summary> public void Dispose() { _port?.Dispose(); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { _comPort.Dispose(); }