public int close(DeviceHandle handle) { if (handle == null) { _log.Warn("Called with null handle"); return 0; } if (handle.isInvalid()) { _log.Warn("Called with INVALID handle"); return 0; } try { Thread.Sleep(200); if (handle.RS232hnd.hnd.IsOpen) { handle.RS232hnd.hnd.Close(); } _log.Debug(handle.RS232hnd.hnd.PortName + " has been closed."); handle.setInvalid(); return 0; } catch (Exception exception) { _log.Error("Close() - " + exception.Message); handle.setInvalid(); return -1; } }
public int close(DeviceHandle handle) { if (handle == null) { _log.Warn("Called with null handle"); return 0; } if (handle.isInvalid()) { _log.Warn("Called with INVALID handle"); return 0; } try { handle.HIDhnd.hnd.Close(); handle.setInvalid(); return 0; } catch (Exception exception) { _log.Error(exception.Message); handle.setInvalid(); return -1; } }