Example #1
0
 public void Dispose()
 {
     _UsbDeviceConnection?.Dispose();
     _UsbDevice?.Dispose();
     _ReadEndpoint?.Dispose();
     _WriteEndpoint?.Dispose();
 }
Example #2
0
 public void Dispose()
 {
     if (NativeDevice != null)
     {
         NativeDevice.Dispose();
         NativeDevice = null;
     }
     if (Connection != null)
     {
         Connection.Dispose();
         Connection = null;
     }
     if (Endpoint != null)
     {
         Endpoint.Dispose();
         Endpoint = null;
     }
     if (EndpointWrite != null)
     {
         EndpointWrite.Dispose();
         EndpointWrite = null;
     }
     if (Manager != null)
     {
         Manager.Dispose();
         Manager = null;
     }
 }
            public override void Close()
            {
                if (mConnection == null)
                {
                    throw new IOException("Already closed");
                }

                if (mControlInterface != null)
                {
                    mControlInterface.Dispose();
                    mControlInterface = null;
                }

                if (mDataInterface != null)
                {
                    mDataInterface.Dispose();
                    mDataInterface = null;
                }

                if (mControlEndpoint != null)
                {
                    mControlEndpoint.Dispose();
                    mControlEndpoint = null;
                }

                if (mReadEndpoint != null)
                {
                    mReadEndpoint.Dispose();
                    mReadEndpoint = null;
                }

                if (mWriteEndpoint != null)
                {
                    mWriteEndpoint.Dispose();
                    mWriteEndpoint = null;
                } //richard: dispose to avoid GREF leak

                mConnection.Close();
                mConnection.Dispose();//richard: dispose to avoid GREF leak
                mConnection = null;
            }