コード例 #1
0
        internal void Close()
        {
            if (_alreadyDisposed)
            {
                throw new ObjectDisposedException("");
            }

            if (_hDevice != CyConst.INVALID_HANDLE)
            {
                PInvoke.CloseHandle(_hDevice);
            }
            _hDevice = CyConst.INVALID_HANDLE;

            if (_hHndNotification != IntPtr.Zero)
            {
                PInvoke.UnregisterDeviceNotification(_hHndNotification);
            }
        }
コード例 #2
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (_alreadyDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                // Free managed members that implement IDisposable
                foreach (USBDevice u in Items)
                {
                    u.Dispose();
                }
            }

            // Free the un-managed resources (handles)
            foreach (IntPtr h in hDevNotifications)
            {
                PInvoke.UnregisterDeviceNotification(h);
            }

            _alreadyDisposed = true;
        }