/// <summary> /// Retrieves the IPInfo for the machine on the local network with the specified MAC Address. /// </summary> /// <param name="macAddress">The MAC Address of the IPInfo to retrieve.</param> /// <returns></returns> public static IPInfo GetIPInfo(string macAddress) { var ipinfo = (from ip in IPInfo.GetIPInfo() where ip.MacAddress.ToLowerInvariant() == macAddress.ToLowerInvariant() select ip).FirstOrDefault(); return(ipinfo); }
private void getIPInfo(object data) { var ipinfoFound = false; var count = 0; // count is used to only check a certain number of times before giving up // This will keep the thread from preventing the app from exiting when the user closes the main window. while (!ipinfoFound && count < 10) { try { var pd = data as PeerDevice; var ipinfo = IPInfo.GetIPInfo(pd.Peer.MacAddress.Replace(":", "-")); if (ipinfo != null) { var hostname = ipinfo.HostName; this.Dispatcher.Invoke((Action) delegate() { this.SetIPInfoDisplay(ipinfo); }); ipinfoFound = true; } else { Thread.Sleep(1000); ipinfoFound = false; } } catch { ipinfoFound = false; } count++; } if (!ipinfoFound) { this.Dispatcher.Invoke((Action) delegate() { this.SetIPNotFound(); }); } }