private void SerialDeviceExpired(string serialNumber, SerialConnectionInfo obj)
        {
            ConnectionSearchResult connectionSearchResult = new ConnectionSearchResult(serialNumber, obj);

            lock (autoConnectionInfoListSyncLock)
            {
                connectionSearchResults.Remove(connectionSearchResult);
            }

            DeviceExpired?.Invoke(connectionSearchResult);
        }
        private void BeginSearchUdp()
        {
            // Set service expiery period to 5 seconds to deal with IMU wifi send delays
            queriesList.Add(AhoyQuery.CreateQuery(5000));

            foreach (IAhoyQuery query in queriesList)
            {
                query.ServiceDiscovered += delegate(AhoyServiceInfo serviceInfo)
                {
                    NetworkInterface networkInterface = GetInterfaceFor(serviceInfo.NetworkAdapterIPAddress);

                    string adapterName = "Unknown adapter";

                    if (networkInterface != null)
                    {
                        adapterName = networkInterface.Description;
                    }

                    ConnectionSearchResult connectionSearchResult = new ConnectionSearchResult(serviceInfo.Descriptor,
                                                                                               new UdpConnectionInfo()
                    {
                        AdapterName      = adapterName,
                        NetworkAdapter   = networkInterface,
                        AdapterIPAddress = serviceInfo.NetworkAdapterIPAddress,
                        SendIPAddress    = serviceInfo.Address,
                        SendPort         = serviceInfo.SendPort,
                        ReceivePort      = serviceInfo.ListenPort,
                    });

                    lock (autoConnectionInfoListSyncLock)
                    {
                        connectionSearchResults.Add(connectionSearchResult);
                    }

                    DeviceDiscovered?.Invoke(connectionSearchResult);
                };

                query.ServiceExpired += delegate(AhoyServiceInfo serviceInfo)
                {
                    NetworkInterface networkInterface = GetInterfaceFor(serviceInfo.NetworkAdapterIPAddress);

                    string adapterName = "Unknown adapter";

                    if (networkInterface != null)
                    {
                        adapterName = networkInterface.Description;
                    }

                    ConnectionSearchResult connectionSearchResult = new ConnectionSearchResult(serviceInfo.Descriptor,
                                                                                               new UdpConnectionInfo()
                    {
                        AdapterName      = adapterName,
                        NetworkAdapter   = networkInterface,
                        AdapterIPAddress = serviceInfo.NetworkAdapterIPAddress,
                        SendIPAddress    = serviceInfo.Address,
                        SendPort         = serviceInfo.SendPort,
                        ReceivePort      = serviceInfo.ListenPort,
                    });

                    lock (autoConnectionInfoListSyncLock)
                    {
                        connectionSearchResults.Remove(connectionSearchResult);
                    }

                    DeviceExpired?.Invoke(connectionSearchResult);
                };

                query.BeginSearch(SendInterval);
            }
        }