Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ResolveHostAdresses(object sender, RoutedEventArgs e)
- {
- string[] hostNames =
- {
- "www.microsoft.com",
- "www.apple.com", "www.google.com",
- "www.ibm.com", "cisco.netacad.net",
- "www.oracle.com", "www.nokia.com",
- "www.hp.com", "www.dell.com",
- "www.samsung.com", "www.toshiba.com",
- "www.siemens.com", "www.amazon.com",
- "www.sony.com", "www.canon.com",
- "www.alcatel-lucent.com", "www.acer.com",
- "www.motorola.com"
- };
- var parallerQuery = hostNames.AsParallel().Select(g => new
- {
- host = g,
- ips = Dns.GetHostAddresses(g)
- });
- var parallerQuery2 = from h in hostNames.AsParallel()
- select new
- {
- host = h,
- ips = Dns.GetHostAddresses(h)
- };
- //StringBuilder result = new StringBuilder();
- //foreach(string hostName in hostNames)
- //{
- // result.Append(hostName + " => ");
- // IPAddress[] ips = Dns.GetHostAddresses(hostName);
- // foreach (IPAddress ip in ips)
- // result.Append(ip.ToString());
- // result.Append("\n");
- StringBuilder result = new StringBuilder();
- foreach (var adress in parallerQuery2)
- {
- result.Append(adress.host + " => ");
- foreach(var ip in adress.ips)
- result.Append(ip.ToString() + "\n");
- }
- this.hostAdressesBox.Text = result.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement