private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    SerialPortService.CleanUp();
                    _COMPort.Dispose();
                    _controller.Dispose();
                    SerialPortService.CleanUp();
                }

                disposedValue = true;
            }
        }