Wraps a profile handle into a System.Runtime.ConstrainedExecution.CriticalFinalizerObject. Profile handles are used for getting device descriptor information and opening the device. Profile handles are known connected and usually supported usb device that can be opened and used.

When a MonoUsbProfileHandle instance is created and wrapped around the libusb_device pointer, MonoUsbApi.RefDevice is called. When all references to this MonoUsbProfileHandle instance are out-of-scope or have all been closed, this profile handle is de-referenced with MonoUsbApi.UnrefDevice. When the reference count equals zero, memory is freed and resources are released.

The MonoUsbProfileHandle class ensures all device profiles get closed and freed regardless of abnormal program terminations or coding errors.

Certain operations can be performed using just the MonoUsbProfileHandle, but in order to do any I/O you will have to first obtain a MonoUsbDeviceHandle using MonoUsbApi.Open.

Inheritance: LibUsbDotNet.Main.SafeContextHandle
        internal MonoUsbProfile(MonoUsbProfileHandle monoUSBProfileHandle)
        {
            mMonoUSBProfileHandle = monoUSBProfileHandle;
            mBusNumber            = MonoUsbApi.GetBusNumber(mMonoUSBProfileHandle);
            mDeviceAddress        = MonoUsbApi.GetDeviceAddress(mMonoUSBProfileHandle);
            GetDeviceDescriptor(out mMonoUsbDeviceDescriptor);

//#if DEBUG
//            Console.WriteLine("Vid:{0:X4} Pid:{1:X4} BusNumber:{2} DeviceAddress:{3}",
//                              mMonoUsbDeviceDescriptor.VendorID,
//                              mMonoUsbDeviceDescriptor.ProductID,
//                              mBusNumber,
//                              mDeviceAddress);
//#endif
        }
        internal MonoUsbProfile(MonoUsbProfileHandle monoUSBProfileHandle)
        {
            mMonoUSBProfileHandle = monoUSBProfileHandle;
            mBusNumber = MonoUsbApi.GetBusNumber(mMonoUSBProfileHandle);
            mDeviceAddress = MonoUsbApi.GetDeviceAddress(mMonoUSBProfileHandle);
            GetDeviceDescriptor(out mMonoUsbDeviceDescriptor);

            //#if DEBUG
            //            Console.WriteLine("Vid:{0:X4} Pid:{1:X4} BusNumber:{2} DeviceAddress:{3}",
            //                              mMonoUsbDeviceDescriptor.VendorID,
            //                              mMonoUsbDeviceDescriptor.ProductID,
            //                              mBusNumber,
            //                              mDeviceAddress);
            //#endif
        }
 /// <summary>Open a device handle from <paramref name="profileHandle"/>.</summary>
 /// <remarks>
 /// <para>A handle allows you to perform I/O on the device in question.</para>
 /// <para>To close a device handle call its <see cref="SafeHandle.Close"/> method.</para>
 /// <para>This is a non-blocking function; no requests are sent over the bus.</para>
 /// <note title="Libusb-1.0 API Note:" type="cpp">The <see cref="MonoUsbDeviceHandle(MonoUsbProfileHandle)"/> constructor is roughly equivalent to <a href="http://libusb.sourceforge.net/api-1.0/group__dev.html#ga8163100afdf933fabed0db7fa81c89d1">libusb_open()</a>.</note>
 /// </remarks>
 /// <param name="profileHandle">A device profile handle.</param>
 public MonoUsbDeviceHandle(MonoUsbProfileHandle profileHandle)
     : base(IntPtr.Zero)
 {
     IntPtr pDeviceHandle = IntPtr.Zero;
     int ret = MonoUsbApi.Open(profileHandle, ref pDeviceHandle);
     if (ret < 0 || pDeviceHandle==IntPtr.Zero)
     {
         lock (handleLOCK)
         {
             mLastReturnCode = (MonoUsbError) ret;
             mLastReturnString = MonoUsbApi.StrError(mLastReturnCode);
         }
         SetHandleAsInvalid();
     }
     else
     {
         SetHandle(pDeviceHandle);
     }
 }
 internal static internal_windows_device_priv GetWindowsPriv(MonoUsbProfileHandle profileHandle)
 {
     internal_windows_device_priv priv = new internal_windows_device_priv();
     IntPtr pPriv = new IntPtr(profileHandle.DangerousGetHandle().ToInt64() + Marshal.SizeOf(typeof(internal_libusb_device)));
     Marshal.PtrToStructure(pPriv, priv);
     return priv;
 }