private async Task <T> GetTransportAsync(IHIDProvider provider, HIDDeviceInformation device, CancellationToken cancellation)
        {
            await _Lock.WaitAsync();

            try
            {
                T   transport = null;
                var uniqueId  = string.Format("[{0},{1}]{2}", device.VendorId, device.ProductId, device.DevicePath);
                if (_TransportsByDevicePath.TryGetValue(uniqueId, out transport))
                {
                    return(transport);
                }
                var hidDevice = provider.CreateFromDescription(device);
                await hidDevice.EnsureInitializedAsync(cancellation);

                transport = create(hidDevice);
                _TransportsByDevicePath.Add(uniqueId, transport);
                return(transport);
            }
            finally
            {
                _Lock.Release();
            }
        }
예제 #2
0
 public IHIDDevice CreateFromDescription(HIDDeviceInformation decription)
 {
     return(new WindowsHIDNetDevice((DeviceInformation)decription.ProviderInformation));
 }