Device.Net: GetConnectedDeviceDefinitionsAsync never finishes

Take this basic example:

using Device.Net;
using Hid.Net.Windows;
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Test.Find();
            Console.ReadLine();
        }
    }

    class Test
    {
        public static async void Find()
        {
            WindowsHidDeviceFactory.Register();
            var devices = await DeviceManager.Current.GetConnectedDeviceDefinitionsAsync(new FilterDeviceDefinition { VendorId = 0x04D9, ProductId = 0x0130 });
            Console.WriteLine("this is never printed to console");
            foreach (var device in devices)
            {
                Console.WriteLine(device.DeviceId);
            }
        }
    }
}

The application hangs before Console.WriteLine("this is never printed to console"); is reached.

Windows 10 x64 with netcore 2.2

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Helllo,

and sorry for being late with my answer.

Its strange but now it seems to work as expected. Maybe I had to restart Visual Studio or the whole system after installing the NuGet package !?

Updated to version 2.7.0 and it’s working also.

Thanks!

Sorry have been busy today. I’ll try providing the screenshots tomorrow or on weekend.

Hi,

I tested the code and it prints on the console, but found that when one (or many) device(s) matches the filter an exception occures in Device.Net.dll and the returned list is empty.

Win 10 (1803, Build 17134.590), 64Bit, .NET 4.6.1