public MessageHandler(string portName, int baudRate, int bufferSize) { this.messageCallbacks = new Dictionary <byte, OnMessageHandler>(); this.OnExceptionMessage = null; this.serial = new SerialConnection(portName, baudRate, bufferSize / 4); this.serial.OnReadBytes += Serial_OnReadBytes; this.buffer = new byte[bufferSize]; this.bufferIndex = 0; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { this.Disconnect(); this.serial.Dispose(); this.serial = null; } disposedValue = true; } }