Esempio n. 1
0
        public static async Task <List <Device> > Discover(NetworkInterface preferredInterface)
        {
            List <Task <List <Device> > > tasks = DeviceLocator.CreateDiscoverTasks(preferredInterface, DeviceLocator.MaxRetryCount);

            List <Device>[] result = await Task.WhenAll(tasks);

            return(result
                   .SelectMany(devices => devices)
                   .GroupBy(d => d.Hostname)
                   .Select(g => g.First())
                   .ToList());
        }
Esempio n. 2
0
        public static async Task <List <Device> > Discover()
        {
            var tasks      = new List <Task <List <Device> > >();
            int retryCount = DeviceLocator.MaxRetryCount;

            foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()
                     .Where(n => n.OperationalStatus == OperationalStatus.Up))
            {
                tasks.AddRange(DeviceLocator.CreateDiscoverTasks(ni, retryCount));
            }


            List <Device>[] result = await Task.WhenAll(tasks);

            return(result
                   .SelectMany(devices => devices)
                   .GroupBy(d => d.Hostname)
                   .Select(g => g.First())
                   .ToList());
        }